This has driven me bonkers several times in the last decade! And its back again.
Is there any way to "get at" the standard popup menus for a control? What I want to do is, in the form code, manipulate just one of the menu items. An example being a simple textbox. Among the items is "Delete", now if the textbox contains a primary key I want to disable the Delete menu item. I don't want to have to re-implement the other menu items, Undo/Redo/Cut/Copy/Paste just the Delete.
Has anyone ever managed this?
b
The standard control menus
- Quincunxian
- Posts: 180
- Joined: Sunday 25th June 2017 12:14am
- Location: Western Australia
Re: The standard control menus
Not sure if this will work for you but may give you some ideas toward solving your problem.
I had the same issue where I wanted to display one of more pop-up menu items and disable the others.
I used this subroutine:
Example of calling the subroutine:
with EdtPopup being the popup menu of the specific component in question.
This would disable the menu optioos 'Needs Edit' & 'Add Scene'
I had the same issue where I wanted to display one of more pop-up menu items and disable the others.
I used this subroutine:
Private Sub SetMenuOptions(InMenu As Menu, InName As String, InMode As Boolean)
Dim TmpMnu As Menu
Dim TmpAry As String[]
Dim TmpInt As Integer
If InName = "" Then 'Set ALL menus to the required mode.
For Each TmpMnu In InMenu.Children
TmpMnu.Enabled = InMode
Next
Else 'Set selected menus (by name) to the required mode.
TmpAry = Split(InName, ",")
For Each TmpMnu In InMenu.Children
For TmpInt = 0 To TmpAry.Max
If String.UCase(TmpMnu.Text) = String.UCase(TmpAry[TmpInt]) Then TmpMnu.Enabled = InMode
Next
Next
Endif
End
Example of calling the subroutine:
SetMenuOptions(EdtPopup, "Needs Edit,Add Scene", False)
with EdtPopup being the popup menu of the specific component in question.
This would disable the menu optioos 'Needs Edit' & 'Add Scene'
Cheers - Quin.
I code therefore I am
I code therefore I am
- cogier
- Site Admin
- Posts: 1153
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: The standard control menus
I hope I have understood what you are trying to do. Have a look at the attached.
- BruceSteers
- Posts: 1755
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: The standard control menus
I don't think it's possible to override single menu actions.
Possibly in a gambas control you could override a single menu method but i would not imagine a c-code toolkit one is possible.
I guess you know how to override the whole menu in the mouse events.
Possibly in a gambas control you could override a single menu method but i would not imagine a c-code toolkit one is possible.
I guess you know how to override the whole menu in the mouse events.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: The standard control menus
Mmmm maybe I wasn't clear enough.
Following my example textbox. It has a popup menu that is there compliments of the GUI or something inside Gambas itself. I don't know.
If I try to set the form designer control popup menu to a menu that I have defined for the form, then the natural menu disappears and I have to create a) the whole menu and b) the implementation for each item. Let's just take Undo and Redo. The code to achieve that is already there inside the black box. However, if I make a popup menu for the form then if I want to have Undo/Redo items than I have to code handlers for them. I dont want to have to do that!
On the other hand, if I just want to disable the Paste item (for some ridiculous reason) then I am forced into the above - where I have to implement the whole damn menu (or just the parts of it I do want.)
What I want is to do
Pretty simple desire. Surely someone has come across this before. The sheer idea of having to code an Undo/Redo stack in the form is silly.
Following my example textbox. It has a popup menu that is there compliments of the GUI or something inside Gambas itself. I don't know.
If I try to set the form designer control popup menu to a menu that I have defined for the form, then the natural menu disappears and I have to create a) the whole menu and b) the implementation for each item. Let's just take Undo and Redo. The code to achieve that is already there inside the black box. However, if I make a popup menu for the form then if I want to have Undo/Redo items than I have to code handlers for them. I dont want to have to do that!
On the other hand, if I just want to disable the Paste item (for some ridiculous reason) then I am forced into the above - where I have to implement the whole damn menu (or just the parts of it I do want.)
What I want is to do
TextBox1.NativeMenu["mnuPaste"].Enabled = False
Pretty simple desire. Surely someone has come across this before. The sheer idea of having to code an Undo/Redo stack in the form is silly.
- BruceSteers
- Posts: 1755
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: The standard control menus
I think i understood.
Maybe Benoit knows a way to hack into it but i can't imagine you can access the toolkit controls inner workings like that because they are inner workings.
Maybe Benoit knows a way to hack into it but i can't imagine you can access the toolkit controls inner workings like that because they are inner workings.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: The standard control menus
My brain hurts.
Apparently in GTK this is simple.
In QT5 the problem is well known but un-resolved.
GTK provides access to internal popup menus as a gtk_menu_popup object (which doesn't work with wayland hahahah but who cares.)
There is approximately 2.13 galaxies of web hits regarding this re QT, but I have yet to find an answer. Hence my brain problem. I need a scotch, or two, or
cheers
b
Apparently in GTK this is simple.
In QT5 the problem is well known but un-resolved.
GTK provides access to internal popup menus as a gtk_menu_popup object (which doesn't work with wayland hahahah but who cares.)
There is approximately 2.13 galaxies of web hits regarding this re QT, but I have yet to find an answer. Hence my brain problem. I need a scotch, or two, or
cheers
b
- BruceSteers
- Posts: 1755
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: The standard control menus
Sounds like you need to talk to Ben.
If anyone knows how to do it or can provide a way to do it it'll be Benoit
If anyone knows how to do it or can provide a way to do it it'll be Benoit
If at first you don't succeed , try doing something differently.
BruceS
BruceS