Re: EditorGadget bug (copy/cut/paste)?
Posted: Tue Sep 08, 2015 7:50 pm
It's only a little bit more complicated in Windows! In Linux and MacOS X it works automagically as you would expect...marcoagpinto wrote:Buaaaaaaaa... I want to cry.... even the forum EditorGadget allows the popup menu... how can it need me to code it for PB?

I have taken RASHAD's example and set the Windows specific stuff in CompilerIf...CompilerEnd blocks. Then I have tested the following example successfully with PB 5.31 on these operating systems:
- Kubuntu 14.04 x64
- MacOS X 10.6.8 (Snow Leopard)
- Windows 7 SP1 x64
In the following snapshots you can see that the context menus on Linux and MacOS X differ from our simple Windows popup menu by offering further selectable options.
Kubuntu 14.04:

MacOS X 10.6.8:

Windows 7:

Code: Select all
OpenWindow(0, 100, 100, 300, 190, "Display context menu on right click")
EditorGadget(0, 10, 10, 280, 170)
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
If CreatePopupMenu(0)
MenuItem(0, "Cut")
MenuItem(1, "Copy")
MenuItem(2, "Paste")
EndIf
CompilerEndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Case #PB_Event_Menu
Select EventMenu()
Case 0
SendMessage_(GadgetID(0), #WM_CUT, 0, 0)
Case 1
SendMessage_(GadgetID(0), #WM_COPY, 0, 0)
Case 2
SendMessage_(GadgetID(0), #WM_PASTE, 0, 0)
EndSelect
Case #WM_RBUTTONDOWN
If EventGadget() = 0
DisplayPopupMenu(0, WindowID(0))
EndIf
CompilerEndIf
EndSelect
ForEver