Page 1 of 1

Capturing keys in editorgadget

Posted: Thu Jun 10, 2010 1:53 pm
by BjornF
Is there an easy way to capture the keys as they are entered in the Editorgadget? (When the Return key is pressed I want the contents of the editorgadget to be transferred to a database, and the editorgadget "emptied".)

As far as I understand it "KeyboardPushed" etc don't activate the Waitevent, is that right? (The examples I have found all seem to be using Repeat - Until)

There is no menu-item for the event so I can't use the "AddKeyboardShortcut"

All the best / Björn

Re: Capturing keys in editorgadget

Posted: Thu Jun 10, 2010 1:59 pm
by Arctic Fox
For Windows you can use GetAsyncKeyState_(#VK_RETURN) or subclass the editor gadget.

Why can't you use AddKeyboardShortcut()? It seems to work fine.

Code: Select all

OpenWindow(0, 100, 100, 300, 300, "")
EditorGadget(0, 5, 5, 290, 290)

AddKeyboardShortcut(0, #PB_Shortcut_Return, 1)

Repeat
  Event = WaitWindowEvent()
  
  If EventMenu() = 1 And GetActiveGadget() = 0
    Debug GetGadgetText(0)
    SetGadgetText(0, "")
  EndIf
  
Until Event = #PB_Event_CloseWindow

End

Re: Capturing keys in editorgadget

Posted: Thu Jun 10, 2010 2:05 pm
by BjornF
I must have misunderstood the help file - I thought that you had to have a Menu item that was to be activated by the AddKeyboardShortcut().

Thank you for the rapid help :D

Björn