How can I make cursor dwell "click" a menu item?
-
Wednesday, April 11, 2012 8:40 PM
I have a submenu whose items should be selectively greyed out (Enabled=False), and I depend on the parent menu to be clicked. In VB6, from which I'm migrating, dwelling on the parent item with the cursor raised the Click() event, and the submenu items were enabled or disabled in the Click() routine.
In VS 2008 (and I assume probably in VS 2010), the submenu items are displayed as enabled and can be directly selected, bypassing the parent item, by the user even though some should be disabled.
If, dispite the apparent availability of ungreyed items, the parent item is explicitly clicked, then the submenu items are correctly initialized.
What change should I make to ensure Click() processing occurs before submenu display?
Price Buhrman
- Edited by BuhrmanP Wednesday, April 11, 2012 8:41 PM spelling
All Replies
-
Wednesday, April 11, 2012 8:49 PMI don't know the answer, but perhaps you can get something from the MouseHover event which I believe is the .net equivalent of dwelling.
-
Wednesday, April 11, 2012 9:33 PMYou can handle the DropDownOpened event of the parent menu item to enable/disalbe the sub items.
Armin
-
Thursday, April 12, 2012 5:54 AM
Buhrman,
I cannot get the same behaviour like you, maybe can you tell what I miss in this code to get your behavior
Option Strict On Option Explicit On Option Infer On Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load StopToolStripMenuItem.Enabled = False End Sub Private Sub GoToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles GoToolStripMenuItem.Click StopToolStripMenuItem.Enabled = True GoToolStripMenuItem.Enabled = False End Sub Private Sub StopToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles StopToolStripMenuItem.Click GoToolStripMenuItem.Enabled = True StopToolStripMenuItem.Enabled = False End Sub End Class
Success
Cor -
Thursday, April 12, 2012 10:13 AM
Cor,
if you add sub menus to the "Start" menu you won't get a click event for the "Start" menu in order to be able to enable/disable the sub menu items. Maybe you get a Click for the "Run" menu, but at that point in time it's not necessary yet to dis/enable the sub items of the "Start" menu. I guess that's what the OP meant. Let's wait and see. :)
Armin
-
Thursday, April 12, 2012 1:45 PM
I'm not referring to a tool strip, but to the "regular" menu buttons. My tree looks like the following:
View --> Specials... --> list-of-choices
The Specials... line has a block arrow head on the right. (The ... suffix was inherited from VB6.).
After posting my question, I thought of moving the Enable/Disable code to the View_Click() sub; then I thought about the possiblity of both the View and the Specials... being clicked. Can I have one Click() sub call another Click() sub directly?
Price Buhrman
-
Thursday, April 12, 2012 1:55 PM
Yes
The otherclickmethod(sender, nothing)
or if the eventargs are the same
theotherclickmethod(sender,e)
Success
Cor -
Thursday, April 12, 2012 3:17 PM
Handle the Popup event ot the "Specials" menu item.Armin
- Marked As Answer by BuhrmanP Thursday, April 12, 2012 5:13 PM
-
Thursday, April 12, 2012 5:13 PM
After realizing that, upon clicking the View button, nothing would be happening in my app to alter its states until the whole menu sequence was complete, I decided to move the code from the Specials... Click() sub up to the View Click() sub. That worked perfectly, and it made Specials... processing moot.
But thank you all for your thought-provoking suggestions! (Armin's post seems to recommend the sort of thing I did.)
Price Buhrman

