PDA

View Full Version : How to link a window to a taskbar button ?



Elfayer
18 Jul 2012, 12:31 AM
Hi,

I have a basic desktop. I can open windows with icons on background, I have a minimize tool button (minimizable = true) and I have a taskbar (toolbar).

Now I would like to link somehow the window to a taskbar button, so that I can show or hide the window with a click on the taskbar button, even with the minimize button of the window, etc...

I don't want to charge and see that I choose a wrong way to do it. So I ask for some advices.

If it's not clear enough and if you need more informations, tell me.

Thank you in advance !

Farish
18 Jul 2012, 12:58 AM
you can add a listener to the button:


button.on('click', function() {
if(window.isHidden())
window.show();
else
window.hide();
});

Elfayer
18 Jul 2012, 1:31 AM
Ok, but there are going to be many buttons and windows. If I click on the "Toto app" button it has to only hide or show that window. How can I know that that button refer to that window ?

And on the web desktop demo, they have a scroller when the taskbar has too many buttons, how do they do that ? (I read the source code, but didn't hunderstand)

redraid
18 Jul 2012, 1:49 AM
You can simply store reference to window in button:


// button handler
handler: function (btn) {
var win = btn.win;

if (!win) {
win = //create window
btn.win = win;
}

if (win.isVisible()) {
win.hide(btn);
} else {
win.show(btn);
}
}