Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Enter key detection in dialog

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 403 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post