[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4668: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4670: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4671: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4672: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3815)
XWidgetSoft Forum • View topic - BUG: XWidget does not capture a keypress on an image

XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently April 16th, 2024, 12:20 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: December 9th, 2015, 6:25 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609


Last edited by yereverluvinuncleber on June 28th, 2017, 5:56 am, edited 3 times in total.

Top
 Profile  
 
PostPosted: December 9th, 2015, 6:33 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
Check this widget and the script:
http://subhanulhaque.deviantart.com/art ... -339438490
This guy created a virtual keyboard..

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: December 9th, 2015, 7:17 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
Thanks Jim for the attempt to help.

Yes he did create a virtual keyboard but he didn't capture a CTRL key, his keyboard just has images that respond and add characters on a screen. There was no ctrl key and he didn't handle the event. Interesting widget though...


Top
 Profile  
 
PostPosted: December 9th, 2015, 7:42 am 
Offline
User avatar

Joined: December 5th, 2012, 5:52 pm
Posts: 4887
I found this:
http://help.adobe.com/en_US/AS2LCR/Flas ... 00520.html

_________________
...and remember: don't take life too seriously...
My profile on Deviantart: http://jimking.deviantart.com/


Top
 Profile  
 
PostPosted: December 9th, 2015, 5:23 pm 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
Let me see what I can do with it.


Top
 Profile  
 
PostPosted: December 23rd, 2015, 4:27 pm 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
It seems that you cannot capture keypress events when manipulating any object other than an text edit box or similar. This is a problem as it means that a press of the CTRL key when the mouse is over the widget cannot be captured even though we have an onKeyDown event set up and code assigned. The event is simply ignored.

I tested a very large edit box at an opacity of 1 that can be set over the whole widget, this would have allowed a CTRL key to be captured, unfortunately mouse-through does not seem to work with edit boxes so all other onMouse events for all other images sitting below are negated when a large edit box is positioned above them.

So, to sum up: Xwidgets has an incomplete implementation of onKeyDown event that does not currently function on image objects. This is a BUG. Changing the title of this thread to a BUG.


Top
 Profile  
 
PostPosted: April 25th, 2017, 5:23 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
BUMP:

This bug is a very serious one, it means that Xwidgets cannot respond to keypress events. That makes it useless for creating keyboard driven apps that respond to key events.

For example, when using youtube to display videos the spacebar, cursor and other keys can be used to control the video. These keypresses have become the standard for media players and allow the user to interact with the app using the keyboard if he wishes.

Xwidget does not allow this interaction due to a shoddy implementation of the keydown event.


Top
 Profile  
 
PostPosted: June 28th, 2017, 6:13 am 
Offline
User avatar

Joined: July 29th, 2013, 9:13 am
Posts: 609
Workaround

I tried various methods of getting round this, I tested a very large edit box at an opacity of 1% that can be set over the whole widget, this would have allowed a CTRL key to be captured. Unfortunately, mouse-through does not seem to work with edit boxes so all onMouse events for all other objects sitting below are negated when a large edit box is positioned directly above them.

There is however a isKeyDown() function that checks for a keydown event that actually works...

To capture a keydown event the isKeyDown() function has to be inserted into a place in your code, typically an event function. For example, during a onMouseDown event this code might be inserted:

Code:
if (isKeyDown(40)) {
// right volume up
if (debugFlg === 1) {print("%KON-I-INFO, pressing down the cursor UP key ");};
sliderSet.left = sliderSet.left - 10 ;
limitSliderSet();
}

However, this would only capture the keydown event when the mousekey was pressed simultaneously. So, we have to be inventive to ensure that the only trigger for the keypress is the keypress itself and as a result it needs to be inserted into something keyboard/mouse-neutral that occurs all the time... there aren't many of those - except for a timer event!

Create a timer called keyTimer and set the frequency to 50ms, insert the above code into the keytimerOnUpdate function. This will cause the timer to activate the function every 50ms and determine whether a valid keypress has been made. This is the workaround I was looking for, a bit over-complex for a simple key capture but in the absence of a working onKeyDown function it must suffice.

The isKeyDown(keyCode) function uses the standard javascript keyboard scan codes to determine which key is pressed. Find those here: keycode.info/

There is an unexpected side-effect, the key capture occurs all the time and not just when the widget has focus. The isKeyDown function works whether you are typing into a word processor or writing an email, if the widget is running on your dektop you will find the media player reacting seemingly randomly to your email keypresses. To get round this you simply need to turn off the timer when your mouse leaves the widget and then turn the timer back on when the mouse re-enters. In the IDE in design mode, select the WIDGET object and enable an event for both entering and leaving the widget, assigning the following code:

Code:
function widgetOnEnter()
{
keyTimer.enabled=true;
}

function widgetOnLeave()
{
keyTimer.enabled=false;
}

The regular frequency of the timer could be increased to 100ms interval to reduce the cpu overhead of such a frequently run timer. Unfortunately, the result would be that keypresses would seem 'halting' and jerky in their capture. The 50ms interval makes for smooth response while a 100ms interval feels unresponsive and 'wrong'. There is a cpu penalty for frequently running such a function and it is only necessary due to incomplete features in the Xwidget engine.

However, we have a workaround for the absence of the onKeyDown event and it means that we can now say that Xwidget does have the ability to capture a keyboard event.

Note that this is a limited workaround as the mouse cursor needs to be hovering over the widget in order for this to work. It should operate when the widget gains focus and only stop capturing keypresses when the widget loses focus.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Powered by phpBB® Forum Software © phpBB Group