Right click menu on EditorGadget!

Just starting out? Need help? Post your questions and find answers here.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Right click menu on EditorGadget!

Post 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.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

*bump*
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post 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
;;;;;
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Right click menu on EditorGadget!

Post by PB »

@Bonne: You don't have to bump on the same day... have some patience.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

The string gadget menu is automatic for string gadget. To create one for editor gadget you need to do it manually.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post 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.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post 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
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post 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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post 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.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
omit59
User
User
Posts: 63
Joined: Fri Mar 11, 2005 8:41 am
Location: Finland

Post 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
Post Reply