Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
EDIT shortcut menu - weird behavior.
Message
 
À
19/08/2006 04:33:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Divers
Thread ID:
01146812
Message ID:
01147191
Vues:
47
This message has been marked as a message which has helped to the initial question of the thread.
Modifications to the code of Herman and Fabio to make it work:

*-- Herman's code
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


DEFINE CLASS form1 AS form

   Top = 0
   Left = 0
   Height = 201
   Width = 312
   DoCreate = .T.
   Caption = "Form1"


   ADD OBJECT edit1 AS editbox WITH ;
      Height = 80, ;
      Left = 26, ;
      Top = 14, ;
      Width = 259, ;
      Value = 'Shortcut works properly here' + chr(13) + ;
         'But the shortcut is not display on cursor position'


   ADD OBJECT edit2 AS editbox WITH ;
      Height = 80, ;
      Left = 26, ;
      Top = 106, ;
      Width = 259, ;
      Value = 'Shortcut does not work properly here' + chr(13) + ;
         'The shortcut is display on cursor position'


   PROCEDURE DefinePopup
      DEFINE POPUP FoxShortcutMenu SHORTCUT RELATIVE FROM MROW(),MCOL()
      DEFINE BAR _med_undo OF foxshortcutmenu PROMPT "\<Undo" ;
         KEY CTRL+Z, "Ctrl+Z"
      DEFINE BAR _med_redo OF foxshortcutmenu PROMPT "Re\<do" ;
         KEY CTRL+R, "Ctrl+R"
      DEFINE BAR _med_sp100 OF foxshortcutmenu PROMPT "\-"
      DEFINE BAR _med_cut OF foxshortcutmenu PROMPT "Cu\<t" ;
         KEY CTRL+X, "Ctrl+X"
      DEFINE BAR _med_copy OF foxshortcutmenu PROMPT "\<Copy" ;
         KEY CTRL+C, "Ctrl+C"
      DEFINE BAR _med_paste OF foxshortcutmenu PROMPT "\<Paste" ;
         KEY CTRL+V, "Ctrl+V"
      DEFINE BAR _med_pstlk OF foxshortcutmenu PROMPT "Paste \<Special..."
      DEFINE BAR _med_clear OF foxshortcutmenu PROMPT "Cle\<ar"
      DEFINE BAR _med_sp200 OF foxshortcutmenu PROMPT "\-"
      DEFINE BAR _med_slcta OF foxshortcutmenu PROMPT "Se\<lect All" ;
         KEY CTRL+A, "Ctrl+A"
      DEFINE BAR _med_sp300 OF foxshortcutmenu PROMPT "\-"
      DEFINE BAR _med_find OF foxshortcutmenu PROMPT "\<Find..." ;
         KEY CTRL+F, "Ctrl+F"
      DEFINE BAR _med_repl OF foxshortcutmenu PROMPT "R\<eplace..." ;
         KEY CTRL+L, "Ctrl+L"
   ENDPROC


   PROCEDURE Unload
      Release popup FoxShortcutMenu
   ENDPROC


   Procedure Init
      ThisForm.DefinePopup()
   EndProc

   PROCEDURE edit1.RightClick
      Move Popup FoxShortcutMenu to Mrow(0), Mcol(0)   && <<---------<<
      ACTIVATE POPUP FoxShortcutMenu  && at mrow(), mcol()
   ENDPROC


   PROCEDURE edit2.RightClick
      ThisForm.DefinePopup()  && re-define the popup
      ACTIVATE POPUP FoxShortcutMenu
   ENDPROC

ENDDEFINE
*-- Fabio's code
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


DEFINE CLASS form1 AS form


	Desktop = .T.
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT edit1 AS editbox WITH ;
		Height = 130, ;
		Left = 74, ;
		Top = 28, ;
		Width = 228, ;
		Name = "Edit1"


	PROCEDURE Unload
		RELEASE POPUPS EDIT
		RELEASE MENUS thisform
	ENDPROC


	PROCEDURE Load

		DEFINE MENU thisform BAR IN (this.Name)

		DEFINE PAD Edit OF thisform PROMPT "Edit"
		ON PAD Edit OF thisform ACTIVATE POPUP Edit

		DEFINE POPUP Edit SHORTCUT RELATIVE FROM MROW(),MCOL()
		DEFINE BAR _med_undo OF Edit PROMPT "\<Undo" ;
		 KEY CTRL+Z, "Ctrl+Z"
		DEFINE BAR _med_redo OF Edit PROMPT "Re\<do" ;
		 KEY CTRL+R, "Ctrl+R"
		DEFINE BAR _med_sp100 OF Edit PROMPT "\-"
		DEFINE BAR _med_cut OF Edit PROMPT "Cu\<t" ;
		 KEY CTRL+X, "Ctrl+X"
		DEFINE BAR _med_copy OF Edit PROMPT "\<Copy" ;
		 KEY CTRL+C, "Ctrl+C"
		DEFINE BAR _med_paste OF Edit PROMPT "\<Paste" ;
		 KEY CTRL+V, "Ctrl+V"
		DEFINE BAR _med_pstlk OF Edit PROMPT "Paste \<Special..."
		DEFINE BAR _med_clear OF Edit PROMPT "Cle\<ar"
		DEFINE BAR _med_sp200 OF Edit PROMPT "\-"
		DEFINE BAR _med_slcta OF Edit PROMPT "Se\<lect All" ;
		 KEY CTRL+A, "Ctrl+A"
		DEFINE BAR _med_sp300 OF Edit PROMPT "\-"
		DEFINE BAR _med_find OF Edit PROMPT "\<Find..." ;
		 KEY CTRL+F, "Ctrl+F"
		DEFINE BAR _med_repl OF Edit PROMPT "R\<eplace..." ;
		 KEY CTRL+L, "Ctrl+L"

		ACTIVATE MENU thisform
	ENDPROC


	PROCEDURE edit1.RightClick
		lNoSelection=this.sellength=0
		DEFINE POPUP FoxShortcutMenu SHORTCUT RELATIVE FROM MROW(0),MCOL(0)
		DEFINE BAR _med_undo OF foxshortcutmenu PROMPT "\<Undo" ;
		 KEY CTRL+Z, "Ctrl+Z"
		DEFINE BAR _med_redo OF foxshortcutmenu PROMPT "Re\<do" ;
		 KEY CTRL+R, "Ctrl+R"
		DEFINE BAR _med_sp100 OF foxshortcutmenu PROMPT "\-"
		DEFINE BAR _med_cut OF foxshortcutmenu PROMPT "Cu\<t" ;
		 KEY CTRL+X, "Ctrl+X" Skip for m.lNoSelection
		DEFINE BAR _med_copy OF foxshortcutmenu PROMPT "\<Copy" ;
		 KEY CTRL+C, "Ctrl+C" Skip For m.lNoSelection
		DEFINE BAR _med_paste OF foxshortcutmenu PROMPT "\<Paste" ;
		 KEY CTRL+V, "Ctrl+V" Skip for Len(_Cliptext)=0
		DEFINE BAR _med_pstlk OF foxshortcutmenu PROMPT "Paste \<Special..."
		DEFINE BAR _med_clear OF foxshortcutmenu PROMPT "Cle\<ar";
		Skip for m.lNoSelection
		DEFINE BAR _med_sp200 OF foxshortcutmenu PROMPT "\-"
		DEFINE BAR _med_slcta OF foxshortcutmenu PROMPT "Se\<lect All" ;
		 KEY CTRL+A, "Ctrl+A"
		DEFINE BAR _med_sp300 OF foxshortcutmenu PROMPT "\-"
		DEFINE BAR _med_find OF foxshortcutmenu PROMPT "\<Find..." ;
		 KEY CTRL+F, "Ctrl+F"
		DEFINE BAR _med_repl OF foxshortcutmenu PROMPT "R\<eplace..." ;
		 KEY CTRL+L, "Ctrl+L"

		ACTIVATE POPUP FoxShortcutMenu
	ENDPROC


ENDDEFINE
Ben


>Thank you, Fabio. It looks like I'll have to go by the Solution way - programatically enable/disable the menu entries. Not quite what I wanted. :(
>
>
>>afaik, You cannot.
>>
>>On VFP all form's menu are driven with a bunch of C++ procedures,
>>only in these procedures there is the control of the values _med_xxxx
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform