XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently May 2nd, 2025, 8:48 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 20 posts ] 
Author Message
PostPosted: September 4th, 2012, 12:20 am 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
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: September 4th, 2012, 3:06 am 
Offline

Joined: September 2nd, 2012, 2:37 am
Posts: 17
maybe this will work:
Code:
function widgetOnEnter()
{
    //event
}

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


Last edited by Shezoid on September 4th, 2012, 3:06 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: September 4th, 2012, 3:06 am 
Offline
User avatar

Joined: May 12th, 2012, 8:32 pm
Posts: 594
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: September 4th, 2012, 3:08 am 
Offline
User avatar

Joined: May 12th, 2012, 8:32 pm
Posts: 594
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: September 4th, 2012, 6:11 am 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
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: September 4th, 2012, 8:28 am 
Offline

Joined: August 11th, 2012, 3:13 am
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: September 5th, 2012, 11:55 pm 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
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: September 6th, 2012, 10:41 pm 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
Posts: 56
Thank you qiancang! u just made my widget possible

_________________
Image


Top
 Profile  
 
PostPosted: September 7th, 2012, 12:06 am 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
vlad wrote:
Thank you qiancang! u just made my widget possible

you are welcome :D


Top
 Profile  
 
PostPosted: September 7th, 2012, 4:46 am 
Offline

Joined: August 11th, 2012, 3:13 am
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: September 7th, 2012, 6:27 am 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
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 1046 times


Top
 Profile  
 
PostPosted: September 7th, 2012, 11:28 am 
Offline

Joined: August 11th, 2012, 3:13 am
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: September 8th, 2012, 1:28 am 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
Posts: 56
Nice ! The cloning objects is very handy, now i can create unlimited amount of icons 8-)

_________________
Image


Top
 Profile  
 
PostPosted: September 8th, 2012, 5:00 am 
Offline
User avatar

Joined: June 10th, 2012, 5:57 am
Posts: 313
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 989 times


Top
 Profile  
 
PostPosted: September 8th, 2012, 9:03 pm 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
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: September 9th, 2012, 1:33 am 
Offline
User avatar

Joined: May 12th, 2012, 8:32 pm
Posts: 594
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: September 9th, 2012, 5:02 am 
Offline
User avatar

Joined: August 29th, 2012, 2:34 am
Posts: 56
Thanks 8-) Just submitted my project at deviant art, thanks to you guys.

_________________
Image


Top
 Profile  
 
PostPosted: April 13th, 2013, 1:16 pm 
Offline

Joined: April 13th, 2013, 12:39 pm
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: April 13th, 2013, 4:50 pm 
Offline
User avatar

Joined: May 12th, 2012, 8:32 pm
Posts: 594
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: April 13th, 2013, 11:56 pm 
Offline

Joined: April 13th, 2013, 12:39 pm
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 24 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