Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posibble to add altkeyspopup to the extender #511

Closed
tobiasvandriessel opened this issue Jan 12, 2017 · 6 comments
Closed

Posibble to add altkeyspopup to the extender #511

tobiasvandriessel opened this issue Jan 12, 2017 · 6 comments

Comments

@tobiasvandriessel
Copy link

I'm probably pushing you into fury by now with all my requests, but is it possible to use the AltKeysPopUp with an extender? I just noticed this seems to be impossible right now, is that correct?

@Mottie
Copy link
Owner

Mottie commented Jan 12, 2017

Hi @tobiasvandriessel!

It is already possible... the extender layout needs to contain a key, or keys, setup in the alkeypopup altKeys object (ref):

demo

Although, now that I test it, it appears that the popup isn't correctly centered over the extender layout... I'll have to fix that.

@Mottie
Copy link
Owner

Mottie commented Jan 12, 2017

Hmm, and the altKeysPopup breaks after switching layouts...

@tobiasvandriessel
Copy link
Author

Thanks for your quick reply! So, I'll have to add the AltKeysPopup everytime I switch then? That's no big issue :P

The correctly center part isn't that important for me, I think, as I move the div to another place on the screen anyway and would probably need to adjust it anyhow.

@Mottie
Copy link
Owner

Mottie commented Jan 12, 2017

So, calling the altKeysPopup a second time doesn't appear to work... I'll put this on my to-do list for tomorrow...

It's time!

@Mottie Mottie closed this as completed in efd99b6 Jan 13, 2017
@Mottie
Copy link
Owner

Mottie commented Jan 13, 2017

Ok, I think everything is all fixed up! demo

Here is the hex action button code... you will need to call the addAltKeyPopup function. There is also a new popupPosition callback which will let you reposition the popup.

$.keyboard.keyaction.hex = function(kb) {
  hexActive = !hexActive;
  // update state of hex button
  $('.ui-keyboard-hex').toggleClass(kb.options.css.buttonActive, hexActive);
  // toggle hex button
  $keyboard
    .addExtender({
      layout: hexActive ? 'hexpad' : 'numpad'
    })
    .addAltKeyPopup({
      popupPosition: function(kb, data) {
        /*
        {
          $kb         : Keyboard element (jQuery object),
          $key        : Clicked key element (jQuery object),
          $popup      : Popup container (jQuery object),
          kbHeight    : Keyboard element outer height,
          kbWidth     : Keyboard element outer width,
          popupHeight : Popup container height,
          popupWidth  : Popup container width,
          popupLeft   : Popup container left position,
          popupTop    : Popup container top position
        }
        example: tweak position for extender layout
        if (data.$key.closest('.ui-keyboard-extender').length) {
          data.$popup.css('left', data.popupLeft - data.$popup.width() * 1.5);
        }
        */
      }
    });
};

@tobiasvandriessel
Copy link
Author

Ah shiiit, you're just too great haha! Can I get you a beer or something? :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants