I create a MenuItem,
in the target window, I add a Menu Handler and place code there:
How can I change the MenuItem name (from Show to Hide) ?
I create a MenuItem,
in the target window, I add a Menu Handler and place code there:
How can I change the MenuItem name (from Show to Hide) ?
How can I change the MenuItem name
try
Self.MenuBar.MenuAt(0).Text = "Hello"
and there is a event MenuBarSelected to prepare the menu
Not within the Menu Handlers of a Window
You can Enable/Disable or Add/Remove them within Code, (WindowToolbar.RemoveButtonAt(i)
or WindowToolbar.ButtonAt(i).Enabled = False
) but i don’t think you can Show/Hide them.
@Emile_Schwarz, you like to scold others if they haven’t memorized the instructions beforehand. Have you ever looked at the documentation on this topic or at least at examples like the “Dynamic Desktop Toolbar” project?
I really don’t mean it in a bad way…
Don’t be too hard on @Emile_Schwarz , I am also a fan of people doing some homework before asking here.
.Show or .Hide is usually for a Window
i guess you need
Toolbar11.Visible = not Toolbar11.Visible
for the menu text reat the Visible
status
or just use the caption
visibilité du commutateur
Change visibility
I recall the old way, but that… API2 (*) is … I do not have the words for it.
I recalled how to do and so I wrote. Get the error (screen shot) make a search and only found an answer from 2013 that used… Me.Text.
And this is my last time: before I aske a question here, it takes me an hour to haldf day of searches (usually in vain).
(*) to get the whole text of a DesktopListBox, one used .List (no too siple), so . Text ? (No) so, .Value (No). After a long search, I was thinking that I only want the ListBox Contents. So I re-re—read the DesktopListBox and discovered .Contents !
Sorry, but I am not the kid of guy who never search and ask, then left for a day or two and come back to eat the grain people gave.
These days, I wasted more (far more) time to search in the documentation, forum, etc. than to code.
And Lord knows how boring it is to implement a ToolBar. There is material to write an article on “What you better avoid”
I used Google Translate for the text below:
702 / 5 000
I try not to reply to them to avoid getting this kind of text when I’m the one asking a question.
And, after all, what if the documentation was worse in some areas than in others?
So, today, you have to read the documentation (because of the changes),
Search the Forum (if this case has been discussed),
Search the examples (or start by downloading them),
Watch the videos (which don’t have the examples presented).
Maybe it’s time I planted some potatoes; it would be easier
I forgot something: some people we want to help also flag you because they didn’t like something (what? I don’t know).
I asked in this Forum if it is possible to Hide / Show a ToolBar and the answer was Yes.
Most of the time, these users do not need the ToolBar, so I can hide it. They will Show it as needed.
More room ro see the real data.
I suspect some of the reactions stem from misunderstandings due to the language barrier. Perhaps you’d get to your goal faster if you wrote in your native language or used a translation service more often? I use translation services very frequently because I always try to at least use correct English.
But it’s okay to get annoyed sometimes, Emile. Everything’s fine…
After a break, I implemented a solution with a Property and the Meny Text is something like Show/Hide.
Works fine, the Toolbar Show / Hide on demand !
Back to your last entry: sometimes responder does not read the question, they only pick one word and elaborate stating there. Some g-ignore the screen shots.
Markus is correct, the MenuBarSelected
event is the place to change the text of menu items.
Though you can shortcut the code by just using the name of the menu, like so:
FileMasquerToolbar.Text = If(Self.Toolbar11.Visible, "Hide Toolbar", "Show Toolbar")
My goal was (done hours ago) was not to change the text of the menu, it was too create a Toogle menu (and so change the text of the menu).
The Menu Handler is excuted when the user choose the menu, it seems logical to place there that code.
Hoever logical it seems it is wrong, as Markus and Scott have already said. You need to use the MenuBarSelected method, which is called just before the menu will be displayed. This kind of thing is exactly what that method is for.
in your screenshot you tried show and hide and i told you visible is what you are looking for the whole toolbar.
show/hide are methods which the toolbar not have and visible is a property what do the same.
https://documentation.xojo.com/api/user_interface/desktop/desktoptoolbar.html