If we have a Label with Selectable set, we get a nice “edit” menu popup if we right click on the label. I would like to add special entries to that menu, so in the ConstructContextualMenu event on the label, I append my menu item and then Return False.
However, after I add my code in the CCM event, I only see my added menu item. If I return False, isn’t the normal, default menu supposed to appear with my menu item added?
If Index <> 11 Then Return False // I place my labels into control sets
base.Append(New MenuItem(MenuItem.TextSeparator))
base.Append(New MenuItem("Enter barcode(s) for set"))
Return False
I could not find any way to select the content when selectable is not set, but when selectable is set, the code contextual menu is not used.
However, here is a way to get the default edit menu together with your own option :
Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) Handles ConstructContextualMenu as Boolean
for i as integer = 0 to EditMenu.Count-1
base.append(EditMenu.item(i).clone)
next
base.Append(New MenuItem(MenuItem.TextSeparator))
base.Append(New MenuItem("Enter barcode(s) for set"))
End Function
You don’t get the extra options of the default contextual menu. I have no idea how you could obtain them.
You may want to use a read only TextField instead, so you can select. If you set the background color the same color as the window, it could do the trick.
I know there are declares to remove the border. With some luck, someone will post it.
Thanks, @Michel Bujardet - this is what I just uncovered.
However, My basic underlying issue was far more simple - the label at index 11 had somehow become disabled. Returning it to Enabled solved the selectability issue and the convenience menu is appearing, but now MY entries are NOT appearing, so I’m giving your example a shot - makes more since anyway, so the rest of the convenience menu entries are pretty useless for a read-only label :).
Argh - if the label is selectable, the convenience menu is the only thing that appears.
Here’s my solution in pseudo code -
When populating the labels text with "No known barcodes" Then
Disable Selectable
Else // we know the barcodes for the item(s)
Enable Selectable
End If
It’s odd, but that then allows the convenience menu if the contents are known values, allowing selection and copy, but then allows my custom CM to popup if the values are unknown.