XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 Sep 23日 19:19

All times are UTC - 8 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 07:43 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4545
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"..

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


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 13:10 
Offline

Joined: 2013年 Oct 26日 08:17
Posts: 362
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


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 13:24 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4545
Thanks a lot man!!! I will test it after finish my full screen weather widget... :)

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


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 13:51 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4545
Tested hamid but doesn't work.. :?
What I'm doing wrong...

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


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 14:34 
Offline

Joined: 2013年 Oct 26日 08:17
Posts: 362
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:
weather_pro_full_screen [test2].xwp [710.3 KiB]
Downloaded 145 times


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 15:23 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4545
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..??

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


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 15:26 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4545
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..?! :shock:
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! :)

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


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 23日 15:35 
Offline

Joined: 2013年 Oct 26日 08:17
Posts: 362
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,...)


Top
 Profile  
 
 Post subject: Re: Curiosity: ESC key
PostPosted: 2014年 Jul 24日 16:24 
Offline
User avatar

Joined: 2012年 Dec 5日 17:52
Posts: 4545
Here is the final widget using the esc function: :D
viewtopic.php?f=11&t=4846

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


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

All times are UTC - 8 hours


Who is online

Users browsing this forum: Bing [Bot] and 8 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:  

Powered by phpBB® Forum Software © phpBB Group