Page 1 of 1

Re: EditorGadget bug (copy/cut/paste)?

Posted: Tue Sep 08, 2015 7:50 pm
by Shardik
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? :cry:
It's only a little bit more complicated in Windows! In Linux and MacOS X it works automagically as you would expect... :lol:

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:
Image


MacOS X 10.6.8:
Image


Windows 7:
Image

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

Re: EditorGadget bug (copy/cut/paste)?

Posted: Tue Sep 08, 2015 10:28 pm
by marcoagpinto
Can't Fred code it into PB?

Thanks!