When is Key_Press event emitted?

Post Reply
falviani
Posts: 5
Joined: Fri Oct 30, 2020 7:44 pm

When is Key_Press event emitted?

Post by falviani » Thu Nov 19, 2020 5:00 pm

Hi,

My module needs to process text entered by the user, so I have code for the case Key_Press event as follows:

Code: Select all

         if (object instanceof VoltageKeyPressInfo)
         {
            VoltageKeyPressInfo kpi = (VoltageKeyPressInfo) object;
             if ((kpi.IsEnterKey()) || (kpi.IsTabKey()))		// breakpoint here
            {
               String tVal = editableTestNote1.GetText();j
 		//...
            }
            
         }
with a breakpoint set on the test after handling 'object'. I expected this to fire for every keypress. However, it only reaches the test when an enter key is pressed. When is the event supposed to fire? I don't see anything in the documentation...
Thanks in advance,
Frank

arbuxMusic
Posts: 49
Joined: Sun Aug 25, 2019 10:26 am

Re: When is Key_Press event emitted?

Post by arbuxMusic » Fri Nov 20, 2020 9:59 am

I put together a testbed module (at https://github.com/arbuxMusic/voltage-m ... ntExplorer) to see events without using a debugger.

In the testbed, key presses fire on key down for keyboard characters for that component (I am using Windows 10)

Have you tried putting the breakpoint on the previous line to see if you are seeing the same issue still?

falviani
Posts: 5
Joined: Fri Oct 30, 2020 7:44 pm

Re: When is Key_Press event emitted?

Post by falviani » Fri Nov 20, 2020 3:11 pm

Thanks for the reply. Something else is wrong - the final load process seems to have stalled.
The attachment LoadingStalled.png is no longer available
and while the individual modules are shown, none of them will open.
LoadingStalled.png
LoadingStalled.png (12.02 KiB) Viewed 825 times
.
Not sure where to go from here. Compilation claims all is well...

Thanks, Frank

falviani
Posts: 5
Joined: Fri Oct 30, 2020 7:44 pm

Re: When is Key_Press event emitted?

Post by falviani » Fri Nov 20, 2020 3:30 pm

I ran your sample (thanks! well done!) and found that a Key_Press event is never emitted - only a Label_Changed event, when I press tab or enter. If I am not in the editable text, a Key_Press is immediately emitted with a null component. While I can work with this behavior, it makes it impossible to do validation during the input process, which would be ideal . I want the use to be able to enter either a note number (0-127) or note notation (A0, C#3, etc.). In an ideal world, if they were entering C$ or X#4 I'd be able to catch it immediately.

Perhaps I'll pass this on to support, and see what they recommend. It might not be their expected behavior, or they're restricted due to Java limitations.

Again, thanks!

Post Reply