Enter key detection in dialog
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/02/2008 at 16:51, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.1+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
Howdy,What I'm trying to do is, in a non-modal dialog with a "Setup" button have the pressing of the Enter key perform the same action as the "Setup" button. But, I'm having trouble detecting if the Enter Key was pressed. I tried this in GeDialog::Command()
>
\> BaseContainer res; \> if(GetInputEvent(BFM_INPUT_KEYBOARD, res)) \> { \> GePrint("A key was pressed"); \> LONG key; \> res.GetLong(BFM_INPUT_CHANNEL,key); \> if(key == KEY_ENTER) \> { \> GePrint("Enter key was pressed"); \> } \> } \>
This code prints "A key was pressed" but never prints "Enter key was pressed". In fact it prints "A key was pressed" even when I click on the "Setup" button or any of the other option gadgets. :o(
How do you detect when the enter key was pressed so that it would perform the same action as clicking on the "Setup" button?
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/02/2008 at 21:31, xxxxxxxx wrote:
Hi Cactus Dan,
for testing i put this slight variation of your code in a loop, because i have no non-modal dialog at hand.
It prints "A key was pressed" continously so your first condition always seems to be true but the loop is stopped with "Enter key was pressed" when i press ENTER, so the check for the enter key seems to work like this:>
// bool loop= TRUE; \> // while(loop) \> // { \> BaseContainer res; \> if(GetInputEvent(BFM_INPUT_KEYBOARD, res)) \> { \> GePrint("A key was pressed"); \> LONG key= 0; \> if(res.GetLong(BFM_INPUT_CHANNEL,0) == KEY_ENTER) \> { \> GePrint("Enter key was pressed"); \> // loop= FALSE; \> } \> } \> // } \>
best wishes
Yakuza
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/02/2008 at 22:09, xxxxxxxx wrote:
Howdy,
Hmmmm, your code works if I put that in CommandData::Execute(), but it still doesn't seem to detect the Enter key from GeDialog::Command(). :o(
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/02/2008 at 12:18, xxxxxxxx wrote:
Howdy,
Yee-HA! I figured it out.
When I tried printing the value of the "key" variable it printed "1" when the Enter key was pressed, and it printed "2" when the escape key was pressed. After thinking long and hard about it I tried this:
>
\> switch(id) \> { \> case 1: \> GePrint("Enter key was pressed"); \> break; \> } \>
... and it worked!
I reckon since gadget id's are being passed to GeDialog::Command() anyway, it must also be passing a 1 when the Enter key is pressed and a 2 when the Escape key is pressed, for example: OK & Cancel.
Thanks anyway, but again, I figured it out for myself. ;o)
Adios,
Cactus Dan