In my dropdown menu of my toolbar button, I’ve added a sub menu to one item and placed some items into it.
How do I cycle through that submenu and set all items HasCheckMark = false ?
Thanks.
In my dropdown menu of my toolbar button, I’ve added a sub menu to one item and placed some items into it.
How do I cycle through that submenu and set all items HasCheckMark = false ?
Thanks.
The forum is not for us to do your homework for you. With what code have you tried and failed?
“homework”.. yeah ok…
I already have code that loops through the dropdownmenu and set hascheckmark to false.
However it wasn’t setting the submenu items hascheckmark of one item to false.
I never use a submenu before in a dropdown menu of a toolabrbutton before and wasn’t sure why it wasn’t working.
for i as Integer = 0 to lastrowindex
menubutton.Menu.MenuAt(i).HasCheckMark= False
next
Well I wouldn’t want anyone to do my “homework” for me, so just forget it. I’ll just try to figure something else out.
It seems weird that only one item failed to change its checkmark status. Could you upload a project showing the problem?
Well its the submenu items that the checkmark status with the change. I put together this example.
Example
toolbar demo.xojo_binary_project.zip (5.4 KB)
Select in item A-D and checkmark appers. Select different one it removes any previously selected item except for the Sub menu items. Which I wasn’t sure how to loop through those to
change the checkmark status.
However , I think I might have just figured it out, doing some testing.
Ah, I see. You’ll need to detect the submenu and then go into its children. Stick this inside your existing loop.
// Check for a submenu, we'll need to go into its children
if menubutton.Menu.MenuAt(i).Count > 0 then
var mnuSub as DesktopMenuItem = menubutton.Menu.MenuAt(i)
for n as Integer = 0 to mnuSub.LastRowIndex
mnuSub.MenuAt(n).HasCheckMark = false
next n
end
Ah, cool!
What I had come up with is some what close to what you have.
For an example this is what I have:
for i as Integer = 0 to lastrowindex
menubutton.Menu.MenuAt(i).HasCheckMark= False
//only one menu with submenu
if menubutton.Menu.MenuAt(i).Text="SomeMenu" then
var submenuCount as Integer
submenuCount = menubutton.Menu.MenuAt(i).LastRowIndex
for j as Integer = 0 to submenuCount
menubutton.Menu.MenuAt(i).MenuAt(j).HasCheckMark = False
next
end if
next
It works, though I think I like yours better.
Thanks!