XWidgetSoft Forum
https://www.bbs.xwidget.com/

Help with key-press event
https://www.bbs.xwidget.com/viewtopic.php?f=7&t=2104
Page 1 of 1

Author:  Nutu [ September 10th, 2012, 3:19 am ]
Post subject:  Help with key-press event

Is there a way to create an event when a particular key is pressed? For example if the user presses F10 the script:
Code:
run("shutdown.exe -L");

Author:  vlad [ September 10th, 2012, 5:16 am ]
Post subject:  Re: Help with key-press event

I don't know how to capture the keyboard input once you had left you widget (im pretty sure xWidget dont support it). But if you will create a new Edit lets call it "editKey" and set the Visibility to false we can force it 8-) to act as a fake key capture (Because i didn't found any outer way to capture keyboard input, correct me here if im wrong). Se define a new function
Code:
function widgetOnEnter()
{
     editKey.SetFocus();
}

So each time the focus is set to the widget it immoderately activates the Edit box and from here just add to the "editKey" Edit a new function to capture keyboard events
Code:
function editKeyOnKeyDown(Sender,Key,KeyChar,Shift)
{
  print("Key:" + Key);
  print("KeyChar:" + KeyChar);
  print("Shift:" + Shift);
}

The key value for F10 is "121".

But as we all know there is no documentation for xWidget so there is a possible way to maybe somehow capture the keyboard while the widget on the background or else...

Author:  Nutu [ September 10th, 2012, 5:21 am ]
Post subject:  Re: Help with key-press event

It's not exactly what I wanted but it'll work for now. Thanks. Again. o.e You're a genius.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/