Page 1 of 1
Right click menu on EditorGadget!
Posted: Mon Mar 06, 2006 9:24 pm
by Bonne_den_kule
Stringgadget has it, a right click menu where you can undo, cut, paste, etc...
How can I get this menu for the editor gadget.
I'm 100% sure it's Windows API.
Posted: Tue Mar 07, 2006 1:41 pm
by Bonne_den_kule
*bump*
Posted: Tue Mar 07, 2006 1:51 pm
by utopiomania
The snippets below are taken from a simple editor I posted here:
http://www.purebasic.fr/english/viewtopic.php?t=18024
In the OpenMainWindow() procedure:
Code: Select all
;;;;
;EditorGadgets popup menu
If CreatePopupMenu(#IdPopUp)
;Edit main menu items
MenuItem(#IdFileOpen, TxtFileOpen)
MenuItem(#IdFileSave, TxtFileSave)
MenuItem(#IdFileSaveAs, TxtFileSaveAs)
MenuBar()
MenuItem(#IdEditUndo, TxtEditUndo)
MenuItem(#IdEditAll, TxtEditAll)
MenuBar()
MenuItem(#IdEditCut, TxtEditCut)
MenuItem(#IdEditCopy, TxtEditCopy)
MenuItem(#IdEditPaste, TxtEditPaste)
MenuItem(#IdEditClear, TxtEditClear)
MenuItem(#IdEditView, TxtEditView)
MenuBar()
MenuItem(#IdEditFind, TxtEditFind)
MenuItem(#IdEditRepl, TxtEditRepl)
MenuBar()
MenuItem(#IdFilePrint, TxtFilePrint)
MenuItem(#IdFileExplore, TxtFileExplore)
MenuBar()
MenuItem(#IdFileExit, TxtFileExit)
MenuItem(#IdFileExitSave, TxtFileExitSave)
Else
;Create popup menu error
ProcedureReturn 0
EndIf
;;;;
In the event handler:
Code: Select all
;;;;
;Mouseclick Event
Case #WM_RBUTTONDOWN
;Right mouseclick, open editorgadget popup menu
Select GetGadgetState(#Idpanel)
Case 0
;Tab 0, templates editorgadget right clicked
DisplayPopupMenu(#IdPopUp, PanelWinID(#IdPanel, 0))
Case 1
;Tab 1, html source editorgadget right clicked
DisplayPopupMenu(#IdPopUp, PanelWinID(#IdPanel, 1))
EndSelect
;;;;;
Re: Right click menu on EditorGadget!
Posted: Tue Mar 07, 2006 1:53 pm
by PB
@Bonne: You don't have to bump on the same day... have some patience.
Posted: Tue Mar 07, 2006 6:41 pm
by Bonne_den_kule
The menu on the stringgadget is in my locale language (i have a norwegian xp), so it's not manually created by Fred. I think that is just a win api call, but I have not found something on msdn or google.
But thanks for the help, utopiomania.
Posted: Tue Mar 07, 2006 8:19 pm
by Trond
The string gadget menu is automatic for string gadget. To create one for editor gadget you need to do it manually.
Posted: Tue Mar 07, 2006 10:59 pm
by Bonne_den_kule
Trond wrote:The string gadget menu is automatic for string gadget. To create one for editor gadget you need to do it manually.
I search after it at google and found out that you right. The context menu is impleted by api in edit control, but not in rich edit control.
Posted: Wed Jun 14, 2006 4:58 pm
by rsts
Been experimenting with this (and others) and am wondering if there's any way to have a right click apply to an editorgadget ONLY.
Seems when I try this method, no matter how I "segment" it, the right click menu applies to everything on the window. What I would like is a right click menu applying to the editor gadget but not the other items.
Anyone know if it's possible with PureBasic?
cheers
Posted: Wed Jun 14, 2006 5:13 pm
by netmaestro
There are several ways to do it, but I imagine the quickest is to do one more test once you've caught the buttonpress: ChildWindowFromPoint_() equal to GadgetID(#editorgadget). Then call a popupmenu you've created for the purpose instead of your usual one.
Posted: Wed Jun 14, 2006 6:03 pm
by rsts
Man you're on top of things
Will give it a try. It's good to know it's possible and that I'm not spinning my wheels.
cheers
Posted: Thu Nov 01, 2007 4:54 pm
by Psychophanta
It is strange to me that StingGadget has it and EditorGadget doesn't.
Is there any simple way for the standard right click menu to be functional for EditorGadget? I mean not to create a custom menu, but copy the one existing for the StringGadget.
Posted: Fri Nov 02, 2007 6:36 am
by omit59
@Psychophanta:
If this is enough for You:
keyboardshortcuts for EditorGadget (CtRl+C, CtRl+V ...) still work, however there is no visible right click menu, at least on Windows XP
Timo