Checking SHIFT/CTRL/ALT hold in C++ xpcom

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Checking SHIFT/CTRL/ALT hold in C++ xpcom

YuLo
I'd like to check whether modify button SHIFT/CTRL/ALT is hold in xpcom c++.

in XUL tag
<toolbarbutton image="add.png" modifiers="control" oncommand="test();"/>

modifiers="control" - not work. as it is working in tag

<key keycode="VK_F1" modifiers="control" oncommand="test()"/>

I could use addEventListner and monitor PRESS/RELEASE of SHIFT/CTRL/ALT buttons,
But may be there is simpler way to check whether these buttons are hold.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: Checking SHIFT/CTRL/ALT hold in C++ xpcom

Neil-4
YuLo wrote:

>I'd like to check whether modify button SHIFT/CTRL/ALT is hold in xpcom c++.
>
>in XUL tag
><toolbarbutton image="add.png" modifiers="control" oncommand="test();"/>
>  
>
I think that in this case the event will contain the modifiers if the
button is clicked with the mouse (which is the usual case for
toolbarbuttons but not necessarily for other XUL elements).

So you could write oncommand="if (event.ctrlKey) test();"

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: Checking SHIFT/CTRL/ALT hold in C++ xpcom

YuLo
> I think that in this case the event will contain the modifiers if the
>
> button is clicked with the mouse (which is the usual case for
>
> toolbarbuttons but not necessarily for other XUL elements).
>
>
>
> So you could write oncommand="if (event.ctrlKey) test();"
>
>
>
> --
>
> Warning: May contain traces of nuts.

Thank you Neil, again.
It works!
I supposed there is some XPCOM object which can say about keyboard state.
I tried to find it but unsuccessfully.
I thought to use it deep nested c++ functions.
Passing event object not convenient.
Your method solved the problem so far.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: Checking SHIFT/CTRL/ALT hold in C++ xpcom

YuLo
BTW,

<key key="C" modifiers="control alt" oncommand="alert('alt');"/>

not work. event.altKey not help.

But

<key key="C" modifiers="control shift" oncommand="alert('shift');"/>

works.

<key key="C" modifiers="alt shift" oncommand="alert('alt-shift');"/>
works too.


_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: Checking SHIFT/CTRL/ALT hold in C++ xpcom

Neil-4
YuLo wrote:

>BTW,
>
><key key="C" modifiers="control alt" oncommand="alert('alt');"/>
>
>not work.
>
Ctrl+Alt modifiers are reserved by Windows for shortcut hot keys, so you
should avoid them. Additionally some keyboard layouts reserve some
Ctrl+Alt keys in which case this might produce a c with a cedilla.

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul