|
|||
|
Hello!
I'm trying to create a tray icon menu. Code:
Application.SysTray.useDefaultHandler = false;
Menu.onCommand = function(id) {
trace('COMMAND' + id);
}
Application.SysTray.onRClicked = function () {
trayMenu = new Menu;
trayMenu.createPopupMenu();
if(isWinMinimized) { trayMenu.appendItem("id0", "Show); }
else { trayMenu.appendItem("id0", "Hide"); }
//trayMenu.appendItem();
trayMenu.appendItem("id1", "Exit");
trayMenu.setMenu();
trayMenu.show();
}
2. Line trayMenu.appendItem() makes it ~800px*2px 3. I can't make onRClicked handler work in any case 4. I can't get rid of free space, intended for tray menu icons.. What am i doing wrong?
__________________
#define true false //happy debugging, friends |
|
|||
|
Code:
Application.SysTray.useDefaultHandler = false;
// this event will only be fired by the main menu
Menu.onCommand = function(id) {
trace('COMMAND' + id);
}
Application.SysTray.onRClicked = function () {
trayMenu = new Menu;
trayMenu.createPopupMenu();
if(getMainWnd().windowState == "minimized") {
trayMenu.appendItem("id0", "Show");
}
else {
trayMenu.appendItem("id0", "Hide");
}
trayMenu.appendItem();
trayMenu.appendItem("id1", "Exit");
// don't call setMenu, which set the main menu of the program
//trayMenu.setMenu();
getMainWnd().bringToTop();
// the show method returns the command you have selected
var command = trayMenu.show();
if (command == "id0") {
if (getMainWnd().windowState == "minimized") {
getMainWnd().windowState = "normal";
} else {
getMainWnd().windowState = "minimized";
}
} else if (command == "id1") {
getMainWnd().close();
}
}
|
|
|||
|
Thank for the quick answer!
1 problem left: I can't get rid of free space, intended for tray menu icons (in the left part of menu items).
__________________
#define true false //happy debugging, friends |
|
|||
|
Also, i can't find how to add an icon to a simple tray item.
Menu.appendItem(submenu, name) have no such a parameter. Is there a way?
__________________
#define true false //happy debugging, friends |
|
|||
|
Yes, you can add icons to the left of the menu items.
Code:
// absolute icon path name
trayMenu.appendItem("id0", "Show", "c:\\myshow.ico");
Code:
//"myshow.ico" must have been added into the "Resource" list
trayMenu.appendItem("id0", "Show", "myshow.ico");
|
|
|||
|
Hmmm. The icon is not shown, even if i add it to my resource list.
The code: Code:
Application.SysTray.onRClicked = function () {
trayMenu = new Menu;
trayMenu.createPopupMenu();
trace(fileExists("c:\\JavaCup.ico"));
trace(trayMenu.appendItem("id1", "SomeItem", "c:\\JavaCup.ico"));
getMainWnd().bringToTop();
var command = trayMenu.show();
if(command == "id1") {
getMainWnd().close();
}
}
__________________
#define true false //happy debugging, friends |
|
|||
|
I've understood -)
It was sample for working with downloaded icons. I can't make it work anyway. Maybe swfkit version matter? I use swfkit pro 3.0.
__________________
#define true false //happy debugging, friends |
|
|||
|
i've found. It was necessary to use getAdditionalFile("JavaCup.ico").
But nothing can force menuItem to use external icons.. Anyone tried to do this, except me ?
__________________
#define true false //happy debugging, friends |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|