XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
Curiosity: ESC key https://www.bbs.xwidget.com/viewtopic.php?f=7&t=4838 |
Page 1 of 1 |
Author: | Jimking [ July 23rd, 2014, 7:43 am ] |
Post subject: | Curiosity: ESC key |
I was thinking... We can control a layer (hide-fade out) using the "ESC" key..? Like many pc programs that use esc to close a window. I make a full screen widget and I'm wondering if I can use the "ESC" to hide/fade out the layer, instead of use the click on function using a ΧW "button".. |
Author: | hamid [ July 23rd, 2014, 1:10 pm ] |
Post subject: | Re: Curiosity: ESC key |
it's easy, you just need to: 1. Enable "Can Focused" on the object that you want to get the keypress //it's in "other" section of "properties" of any object 2. add the function below to the [OnKeyUp]/[OnKeyDown] event of object that you make "can focus" enabled for it the code for this: Code: function layer1OnKeyDown(Sender,Key,KeyChar,Shift) { if(Key==27) { //write what you want to be done inside this if layer1.Visible=0 } } Notes: 1. keynumber:27 is the esc key 2. you can use: > OnKeyDown Event: to make the function work when the key is pressed down > OnKeyUp Event: to make the function work when the key gets up |
Author: | Jimking [ July 23rd, 2014, 1:24 pm ] |
Post subject: | Re: Curiosity: ESC key |
Thanks a lot man!!! I will test it after finish my full screen weather widget... ![]() |
Author: | Jimking [ July 23rd, 2014, 1:51 pm ] |
Post subject: | Re: Curiosity: ESC key |
Tested hamid but doesn't work.. ![]() What I'm doing wrong... |
Author: | hamid [ July 23rd, 2014, 2:34 pm ] |
Post subject: | Re: Curiosity: ESC key |
problems: 1. first of all, you add an extra } at the end of script 2. your layer that you make "can focused" enabled is in back of other objects, so it can't be focused 3. your "main" Image Object is on the top of all of the objects, so if you want to make focus you can use this object for it, not the layer that behind them also remember that: to make mouse focus [for layers]: it should be visible to be clickable (it means you need a color for it to make it available for mouse) you can make a clickable layer transparent by making its alpha to 1% here's the example: Attachment:
|
Author: | Jimking [ July 23rd, 2014, 3:23 pm ] |
Post subject: | Re: Curiosity: ESC key |
1. I fixed the script.. Quote: 2. your layer that you make "can focused" enabled is in back of other objects, so it can't be focused 3. your "main" Image Object is on the top of all of the objects, so if you want to make focus you can use this object for it, not the layer that behind them 2,3. Strange..since there is only ONE single layer on top and inside it all the objects. The logical thing is that the designer should recognize it as the top object and using this script had to hide all the elements inside it... ![]() But even with alpha 1% what the utility of the "mouse focus" for layer, since after we add objects inside, the layer is not recognized as "top" and at the end doesn't work..?? |
Author: | Jimking [ July 23rd, 2014, 3:26 pm ] |
Post subject: | Re: Curiosity: ESC key |
Quote: here's the example: Attachment: weather_pro_full_screen [test2].xwp [710.3 KiB] But only assigning the function to the "main" image worked..?! ![]() I did the same thing 5 min ago and didn't work... wt..? Anyway.. I'm going to bed and I leave you in peace.. It's 1:30 am here.. Thanks a bunch for all your help and time! ![]() |
Author: | hamid [ July 23rd, 2014, 3:35 pm ] |
Post subject: | Re: Curiosity: ESC key |
1. the child objects will be on the top of parent object > this means when you put objects inside another, those objects will be on the top of that object 2. it is not needed to focus the layer you want to get invisible, you should focus one object to make the function execute (that object that will call the function should be on the top), the function will do the job and it doesn't matter what it does (it can hide other objects,...) |
Author: | Jimking [ July 24th, 2014, 4:24 pm ] |
Post subject: | Re: Curiosity: ESC key |
Here is the final widget using the esc function: ![]() viewtopic.php?f=11&t=4846 |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |