WNavigationBar - MenuItems
Added by Peter Tagwercher almost 4 years ago
My question now is, why do MenuItems without Popup-Menus keep their "selected" background, I would like it to act as a Button, once clicked it does what the button action says but does not keep it's selected-state, pressed-state or whatever you might call that.
I have clicked (no action behind those items so far) "Projekt importieren", "Logout" and at the very last "Verwaltungsbereich". Both previously selected items are dark greyed even if not selected. Is there a function that I would have to add when the "Click" is done? Unselect() or similar?
Thanks in advance.
screenshot.png (8.15 KB) screenshot.png |
Replies (6)
RE: WNavigationBar - MenuItems - Added by Bruce Toll almost 4 years ago
You can use select(--1) to unselect the current item after it is triggered. See: https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WMenu.html#aec1801d047dc0f150d1cc12b801aa6c2
For an example of where it is helpful to remain in a selected state, you can look at the Wt homepage https://www.webtoolkit.eu/wt. If you click on "Documentation" in the navbar, the "Documentation" item remains selected providing a visual indication (along with the URL) of the content that is currently displayed.
RE: WNavigationBar - MenuItems - Added by Roel Standaert almost 4 years ago
You can also use WMenuItem::setSelectable(false)
.
RE: WNavigationBar - MenuItems - Added by Peter Tagwercher almost 4 years ago
Maybe my big thank you was a bit early ;).
What I am adding is a WMenuItem, but select(--1) applies to a WMenu. How would I connect this \"select(1)\" inside the WMenuItem>triggered->connect(....)?
@Roel Janssen, no, setSelectable won't work since I want the item triggered when I click on it and "unselected" right after. But setSelectable(false) makes it "unclickable" at all.
RE: WNavigationBar - MenuItems - Added by Roel Standaert almost 4 years ago
Yeah, I've noticed the triggered()
signal does not get emitted, but the clicked()
signal on the WMenuItem
still works.
RE: WNavigationBar - MenuItems - Added by Peter Tagwercher almost 4 years ago
Wow, what did I do, a strike-through just because I used -1
:)
But, I got that select(-1)
working by adding it to the connect:
import->triggered()->connect([leftMenu, this] {
...
leftMenu->select(-1);
});