XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 Jul 22日 16:38

All times are UTC - 8 hours




Post new topic Reply to topic  [ 20 posts ] 
Author Message
PostPosted: 2012年 Sep 4日 00:20 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
Posts: 56
How to add/remove a costume created event to a object? (In the code, without using the Inspector Functions) ???

_________________
Image


Top
 Profile  
 
PostPosted: 2012年 Sep 4日 03:06 
Offline

Joined: 2012年 Sep 2日 02:37
Posts: 17
maybe this will work:
Code:
function widgetOnEnter()
{
    //event
}

function setEventForWidget()
{
    widget.OnWidgetEnter=widgetOnEnter;
}


Last edited by Shezoid on 2012年 Sep 4日 03:06, edited 1 time in total.

Top
 Profile  
 
PostPosted: 2012年 Sep 4日 03:06 
Offline
User avatar

Joined: 2012年 May 12日 20:32
Posts: 568
Hi,

Code:
 image1.OnClick = "imgclk";



and you need create a function named imgclk


Code:
function imgclk(Sender)
{
  alert( Sender.name + " Clicked");
}

_________________
XWidget Software Developer
[XWidget for Android] [Lastest version of XWidget] [Lastest patch of XWidget]
[XDesktop for Android/Windows]


Top
 Profile  
 
PostPosted: 2012年 Sep 4日 03:08 
Offline
User avatar

Joined: 2012年 May 12日 20:32
Posts: 568
Shezoid wrote:
maybe this will work:
Code:
function widgetOnEnter()
{
    //event
}

function setEventForWidget()
{
    widget.OnWidgetEnter=widgetOnEnter;
}



Event function need function name string, etc:

Code:
widget.onEnter = "widgetOnEnter";

_________________
XWidget Software Developer
[XWidget for Android] [Lastest version of XWidget] [Lastest patch of XWidget]
[XDesktop for Android/Windows]


Top
 Profile  
 
PostPosted: 2012年 Sep 4日 06:11 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
Posts: 56
My aim is to create a short cut add some events to it (Thank to you it all working now :D ) and attach a core to it.
As much as i tried to go around the code and try to hack it, i cannot manage to create a new instance of the core, and I'm not sure if its needed to be attached to the widget or not... help please. :?:

_________________
Image


Top
 Profile  
 
PostPosted: 2012年 Sep 4日 08:28 
Offline

Joined: 2012年 Aug 11日 03:13
Posts: 25
vlad wrote:
...As much as i tried to go around the code and try to hack it, i cannot manage to create a new instance of the core, and I'm not sure if its needed to be attached to the widget or not... help please. :?:


I asked the same question and still no answer...


Top
 Profile  
 
PostPosted: 2012年 Sep 5日 23:55 
Offline
User avatar

Joined: 2012年 Jun 10日 05:57
Posts: 315
hi,vlad,may i know why you want to creat shortcut in code?
if you need a widget with dynamic shortcut number , you can use the shortcutlist core , here is a example:http://www.xwidget.com/xwidget/widgets/system/2012/0415/249.html


Top
 Profile  
 
PostPosted: 2012年 Sep 6日 22:41 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
Posts: 56
Thank you qiancang! u just made my widget possible

_________________
Image


Top
 Profile  
 
PostPosted: 2012年 Sep 7日 00:06 
Offline
User avatar

Joined: 2012年 Jun 10日 05:57
Posts: 315
vlad wrote:
Thank you qiancang! u just made my widget possible

you are welcome :D


Top
 Profile  
 
PostPosted: 2012年 Sep 7日 04:46 
Offline

Joined: 2012年 Aug 11日 03:13
Posts: 25
qiancang wrote:
vlad wrote:
Thank you qiancang! u just made my widget possible

you are welcome :D


Sadly, not mine. qiancang, do you know how to create an instance of any core in script code? I really need it.


Top
 Profile  
 
PostPosted: 2012年 Sep 7日 06:27 
Offline
User avatar

Joined: 2012年 Jun 10日 05:57
Posts: 315
flibio wrote:
qiancang wrote:
vlad wrote:
Thank you qiancang! u just made my widget possible

you are welcome :D


Sadly, not mine. qiancang, do you know how to create an instance of any core in script code? I really need it.


it seems that creating core in code is not available , may i know what function you want? maybe there is another way to reach it :)

here is a example of clone controls in code , hope it will help you
Attachment:
mine_sweeping.rar [8.41 KiB]
Downloaded 345 times


Top
 Profile  
 
PostPosted: 2012年 Sep 7日 11:28 
Offline

Joined: 2012年 Aug 11日 03:13
Posts: 25
Thanks quiancang, I know how create or clone controls in code.
The need of dinamically creating instances of cores comes in order to make a widget which displays information of all the drives. The fix drives aren't a problem, but removable drives such USB or firewire cannot be predefined. You should create a diskcore for every letter of the the system drives, which is highly inefficient. Right now I can do the trick using WMI queries but CPU activity is a little high, and I would rather use the diskcore, but obviously only if I can create it dinamically.

That's my need, but there are a lot of scenarios in which would be interesting create a core dinamically.


Top
 Profile  
 
PostPosted: 2012年 Sep 8日 01:28 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
Posts: 56
Nice ! The cloning objects is very handy, now i can create unlimited amount of icons 8-)

_________________
Image


Top
 Profile  
 
PostPosted: 2012年 Sep 8日 05:00 
Offline
User avatar

Joined: 2012年 Jun 10日 05:57
Posts: 315
flibio wrote:
Thanks quiancang, I know how create or clone controls in code.
The need of dinamically creating instances of cores comes in order to make a widget which displays information of all the drives. The fix drives aren't a problem, but removable drives such USB or firewire cannot be predefined. You should create a diskcore for every letter of the the system drives, which is highly inefficient. Right now I can do the trick using WMI queries but CPU activity is a little high, and I would rather use the diskcore, but obviously only if I can create it dinamically.

That's my need, but there are a lot of scenarios in which would be interesting create a core dinamically.



Hi,flibio, creating core in code is not the only way to meet your need ;)
here is a widget by asia which just uses 4 diskcores but could display all your drives
the code you need is between about line 1 and line 200.
it's a old widget and some code is not necessary in current XWidget
its annotation are Chinese , hope that would not trouble you

And , vlad , some code in this widget is the rudiment of shortcutlistcore , hope it will make your work easier :)
Attachment:
asia disk.rar [472.34 KiB]
Downloaded 355 times


Top
 Profile  
 
PostPosted: 2012年 Sep 8日 21:03 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
Posts: 56
Cheers qiancang! 8-)

Would you have any explanation to me how to use "GetFileIconToPng" function ?
I'm trying to auto generate an icon on each time a link / app has been dropped on my widget.
Code:
   
OnDragDrop(Sender,Data,Point)
{
          iconSrc = GetFileIconToPng(Data, ??);
         
}


_________________
Image


Top
 Profile  
 
PostPosted: 2012年 Sep 9日 01:33 
Offline
User avatar

Joined: 2012年 May 12日 20:32
Posts: 568
Code:
GetFileIconToPng( FileName , PNG FileName);


So,you can uses this to get a PNG from a file into widget's folder named "IconFile.png" :

Code:
OnDragDrop(Sender,Data,Point)
{
  var iconSrc = widgetPath + "IconFile.png";
  GetFileIconToPng(Data, iconSrc );
         
}


_________________
XWidget Software Developer
[XWidget for Android] [Lastest version of XWidget] [Lastest patch of XWidget]
[XDesktop for Android/Windows]


Top
 Profile  
 
PostPosted: 2012年 Sep 9日 05:02 
Offline
User avatar

Joined: 2012年 Aug 29日 02:34
Posts: 56
Thanks 8-) Just submitted my project at deviant art, thanks to you guys.

_________________
Image


Top
 Profile  
 
PostPosted: 2013年 Apr 13日 13:16 
Offline

Joined: 2013年 Apr 13日 12:39
Posts: 7
Hello.
Can you help me to delete cloned object in code. I've clone objects by this code
Code:
ds=new Array();
for (var i=1;i<=Edisks.length;i++)  {
      ds[i] = disk.Clone(roots);  ds[i].Parent = roots;
}
.....

if I use this code to delete item
Code:
ds.splice(0,1); //for example

then the object is not deleted
I tryed to use ds[i].UpdateTargets;
but it didn't work.

Could you give an advice, how to do that?


Top
 Profile  
 
PostPosted: 2013年 Apr 13日 16:50 
Offline
User avatar

Joined: 2012年 May 12日 20:32
Posts: 568
try this code:

Code:
for (var i=1;i<=ds.length;i++)  {
  ds[i].free;
}




Or, you can clone these controls and set their parent to a layer control ,
when you need delete them ,just call layer1.ClearChildren;

Code:
function layer1OnClick(Sender)
{
  layer1.ClearChildren;
  layer1.Repaint;
}


_________________
XWidget Software Developer
[XWidget for Android] [Lastest version of XWidget] [Lastest patch of XWidget]
[XDesktop for Android/Windows]


Top
 Profile  
 
PostPosted: 2013年 Apr 13日 23:56 
Offline

Joined: 2013年 Apr 13日 12:39
Posts: 7
it works, thank you very much


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

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 4 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