Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Retry: Shortcut menu also in main menu
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Divers
Thread ID:
00933420
Message ID:
00933436
Vues:
24
>>Hi to All,
>>
>>Last friday I posted a request for some feedback and no one replied. So, I will retry. Perhaps you skipped the message because it's lacking some concrete code. However, I will not modify the text, because I still expect it is good enough to trigger your thoughts. If you think a piece of code is needed to start the discussion, then I'll post my first, but partly failing, attempt. Here's the text:
>>
>>---
>>
>>I have developed a shortcut menu (for a treeview) that I also want to offer in the main menu, but without having to write the same code twice. The shortcut menu code is in a method of the form. Actually, it is re-initialized each time that the user rightclicks on the treeview, in order to disable certain options and mark other options.
>>
>>The idea is that a user should also be able to choose the menu options via the keyboard, for example if the mouse is unavailable. This design is also dominant in Visual FoxPro itself, for example the project manager's shortcut menu is (largely) repeated in the main menu under the pad Project.
>>
>>Who has already dealt with this design? Any suggestions on how to handle it?
>
>Hi Peter,
>
>First of all, you should expect to be using PRG-based menus, if that isn't already a given. VFP's menu designer is a handy way to get started, but kiss it goodbye after you use it to generate some preliminary sample menu code. You'll have much more flexibility with PRGs, which can take any sort of arguments and support any dynamic behavior you'd like. Instead of putting the common menu logic into a method, just let the method pass an object reference to your menu PRG, or initialize a reserved private memory variable to THIS before invoking the menu program.
>
>HTH
>
>Mike

Hi Mike,

Oh well, let me show some code then. Hope it doesn't confuse you and others.

This is the TreeviewMenu() method:
lparameter tcAction, tcMenuName

local llExpanded, lcAction, lox, i

lcAction = lower( tcAction )

with thisform

	do case
	case inlist( lcAction, 'init shortcut', 'init main' )
		*
		with thisform.pgf.pagMain.oleTreeview
			*
			llExpanded = .Nodes(1).Expanded

* This call is not appropriate if 'init main' is intended. But what is appropriate then?
			DEFINE POPUP treeview SHORTCUT RELATIVE FROM MROW(),MCOL()
			
			DEFINE BAR   1 OF treeview PROMPT "E\<xpand all"
			DEFINE BAR   2 OF treeview PROMPT "\<Collapse all" skip for not llExpanded
			* etc..
		endwith
		*
		ON SELECTION BAR 1 OF treeview goMainWindow.TreeviewMenu( '+' )
		ON SELECTION BAR 2 OF treeview goMainWindow.TreeviewMenu( '-' )
		* etc..
		*
* This call is not appropriate if 'init main' is intended. But what is appropriate then?
		activate popup treeview

	case inlist( lcAction, "+-", "+", "-" )

		do case
		case lcAction == "+-"		&& This action indicates that the current setting must be used.
		case lcAction == "+"		&& Let's expand.
			.lExpanded = .T.
		case lcAction == "-"		&& Let's collapse
			.lExpanded = .F.
		endcase

		lox = .pgf.pagMain.oleTreeview
		.lockscreen = .t.
		lox.visible = .f.

		FOR i = 1 TO lox.Nodes.Count
			lox.Nodes(i).Expanded = .lExpanded
		ENDFOR

		lox.visible = .t.
		lox.setfocus()
		
		.lockscreen = .f.

*	case etc...
	endcase

endwith
And here is the direct command in the built main menu:
goMainWindow.TreeviewMenu( "init main" , "&cMenuName.")
I'll be back tomorrow, because it's now bedtime in Europe. :)
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform