XWidgetSoft Forum

XWidget & XLaunchpad , Desktop customization
It is currently 2017年 May 29日 23:16

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 2013年 Jul 29日 09:17 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 453
Is it possible to create/modify menu items within Xwidget javascript?
If so, please give some pointers, I am trying to replicate the following code:

for example:
mainWindow.onContextMenu = function() {
var items = [];
items[1] = new MenuItem();
items[1].title = "Online Help";
items[1].onSelect = function() {
widgethelp();
};
items[2] = new MenuItem();
items[2].title = "blah blah blah";
items[2].onSelect = function() {
donate();
};
items[3] = new MenuItem();
items[3].title = "blah blah blah";
items[3].onSelect = function() {
amazon();
};
items[4] = new MenuItem();
items[4].title = "blah blah blah";
items[4].onSelect = function() {
rocketdock();
};
items[5] = new MenuItem();
items[5].title = "";
items[5].onSelect = function() {
nullfunction();
};
items[6] = new MenuItem();
items[6].title = "See More blah blah blah;
items[6].onSelect = function() {
otherwidgets();
};
items[7] = new MenuItem();
items[7].title = "Download blah blah blah";
items[7].onSelect = function() {
update();
};
items[11] = new MenuItem();
items[11].title = "Contact blah blah blah";
items[11].onSelect = function() {
contact();
};
mainWindow.contextMenuItems = items;

I would also like to be able to modify the menus dynamically.


Last edited by yereverluvinuncleber on 2014年 Oct 18日 06:05, edited 2 times in total.

Top
 Profile  
 
PostPosted: 2013年 Aug 1日 18:53 
Offline
User avatar

Joined: 2012年 Jun 10日 05:57
Posts: 315
new tutorial:creating menuitem


Top
 Profile  
 
PostPosted: 2013年 Aug 2日 16:15 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 453
Thanks, but I know how to create the menu items using the gui, I just wanted to know If I can create menu items in code using a similar method as shown in the javascript above.


Top
 Profile  
 
PostPosted: 2013年 Aug 8日 04:29 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 453
Hello, can anyone give any feedback as to whether this is possible?


Top
 Profile  
 
PostPosted: 2014年 Oct 12日 06:55 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 453
BUMP

item = new MenuItem();

I am surprised this sort of thing can't be done, can it? It should be possible within the logic so more dynamic menus can be created on-the-fly.

<menu>
<item name="menuitem7" caption="Contact Support" onClick="menuitem7OnClick"/>
</menu>


Top
 Profile  
 
PostPosted: 2014年 Oct 17日 15:55 
Offline

Joined: 2013年 Oct 26日 08:17
Posts: 362
i don't think there is a menuitem.create() function available,
but as another way:

1. create some more menuitems in gui,
2. use [OnPopupMenu] Event and add a function to it,
3. write the function to make them [.Visible],
4. you can also change [.Caption], [.Core], [.OnClick], [.Enabled], [.Checked], [.Tag], [.TagString] (this one is not available in gui :D) ,... through ScriptCode


Top
 Profile  
 
PostPosted: 2014年 Oct 18日 03:34 
Offline
User avatar

Joined: 2013年 Jul 29日 09:13
Posts: 453
Very useful and I will think about it. Changing this post to CLOSED.

Menu items cannot be created in code in Xwidget engine.


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

All times are UTC - 8 hours


Who is online

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

Powered by phpBB® Forum Software © phpBB Group