get selected window on desktop #201
Replies: 2 comments 2 replies
-
|
Hi! By pure chance I just answered a similar question in #196 (comment), but since here you are giving more details of what you are trying to accomplish, I will also give you a more detailed response. In general, using events is the most idiomatic solution to these problems. Taking into account what I said in the other issue, you would have to use a custom broadcast event, like this: const ushort cmFindSelectedWindow = /* ... */;
void TMyApp::getSelectedWindowAndDoSomething()
{
TMyWindow *window = (TMyWindow *) message(deskTop, evBroadcast, cmFindSelectedWindow);
if (window)
// Do something...
}Then, in your custom window class, you have to handle that event only when the window is selected: TMyWindow::TMyWindow(/* ... */)
{
eventMask |= evBroadcast; // The ability to receive broadcast events has to be enabled manually.
}
void TMyWindow::handleEvent(TEvent &event)
{
TWindow::handleEvent(event); // Or whichever TMyWindow's superclass is.
switch (event.what)
{
/* ... */
case evBroadcast:
switch (event.message.command)
{
/* ... */
case cmFindSelectedWindow:
if (state & sfSelected)
clearEvent(event);
break;
}
break;
}
} |
Beta Was this translation helpful? Give feedback.
-
|
I am keeping all the windows i atach to desktop and i look for window->getState(sfSelected) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
when i have multiple windows in the desktop:
desktop->insert(new TWindow(...))The user can select one and the window becomes highlighted.
Can i obtain which window is selected? (desktop->getWindowSelected() or something similar exists?)
Beta Was this translation helpful? Give feedback.
All reactions