VK_PLUS not recognised in menu shortcut

Discussion in 'Java' started by DBloke, Feb 20, 2008.

  1. DBloke

    DBloke Guest

    Hi,

    I am trying to use Ctrl + as a menu shortcut, and am passing the VK_PLUS
    with the ctrl shift mask but this will does not work.

    I have a uk keyboard and the + is above the = the VK_MINUS works fine,
    so I am guessing the problem is to do with the fact that + needs to be
    shifted.

    If I pass in just '+' as the char with a Ctrl Mask i get unknown error
    code 0x002b appear on the menu.

    Passing in just '+' works but does not with the Ctrl Key unsurprisingly.

    Is there a way to map the VK_EQUALS to VK_PLUS so that Pressing Ctrl =
    displays as Ctrl+ Plus on the menu text rather than Ctrl+ Equals?

    Thanks
    DB
     
    DBloke, Feb 20, 2008
    #1
    1. Advertisements

  2. I don't really know myself, but:
    - does the big "+"-key on the numpad-part of the keyboard
    trigger that binding?
    - why would you bind something to a triple-keypress, anyway?
    - are you aware, that other keyboards (e.g. german)
    have a key with "+" in unshifted position?
     
    Andreas Leitgeb, Feb 21, 2008
    #2
    1. Advertisements

  3. DBloke

    DBloke Guest

    Hi, yes I am aware of this :) you have a sensible keyboard.
    I guess what I really want is to press Ctrl and = to trigger event but
    have Ctrl+ Plus display as the menu shortcut. similar to Firefox.

    Looking through the keystroke java class I can not see a way to change
    what text is displayed as the shortcut text in the menu item without
    effectively extending the calss if this is possible, copying the entire
    getkeytext method, overriding this in my class and pasting the sun
    method and have VK_EQUALS return Ctrl+ Plus rather than Ctrl+ Equals,
    this way I can capture the Ctrl + Equals key event but display Ctrl +
    Plus as the shortcut in he menu.

    Firefox use of this must map both equals and + to Ctrl Plus as doing
    either a Ctrl = or a Ctrl Shift + produce the same result.

    I can't believe this is the only way, I thought about overriding key
    Press events, intercepting Ctrl+ Equals and directing to method of
    interest and faking text in menu.

    Anybody got any better ideas?
    DB
     
    DBloke, Feb 21, 2008
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.