PureBoard
http://forums.purebasic.com/german/

DisplayPopupMenu() unter mac
http://forums.purebasic.com/german/viewtopic.php?f=20&t=30142
Seite 1 von 1

Autor:  kevv [ 07.05.2017 00:32 ]
Betreff des Beitrags:  DisplayPopupMenu() unter mac

Hallo
DisplayPopupMenu() funzt nicht sobald man das Fenster windows2 schließt und wieder neu erstellt.
Bug ?
getestet unter osx el capitan 10.11
linux, windows alles ok


Code:
Enumeration FormMenu
  #PopupMenu_info
  #Menu_info_1
EndEnumeration

Procedure RefreshHandler()
  DisplayPopupMenu(#PopupMenu_info, WindowID(EventWindow()))
EndProcedure
Procedure ButtonHandler()
  Window_2 = OpenWindow(#PB_Any, 100, 100, 500, 500, "Window_2", #PB_Window_SystemMenu)
  Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "DisplayPopup")
  BindGadgetEvent(Button, @RefreshHandler())
EndProcedure



Window_1 = OpenWindow(#PB_Any, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
CreatePopupMenu(#PopupMenu_info)
MenuItem(#Menu_info_1, "TEST")
Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "OpenWindow")
BindGadgetEvent(Button, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_CloseWindow
    CloseWindow(EventWindow())
  EndIf
Until Event = #PB_Event_CloseWindow And EventWindow() = Window_1

Autor:  Shardik [ 07.05.2017 09:14 ]
Betreff des Beitrags:  Re: DisplayPopupMenu() unter mac

Das Problem liegt darin, dass in PB unter MacOS anscheinend immer das erste Fenster (Window_1) als Elternfenster in DisplayPopupMenu() angegeben werden muß. Verblüffend ist nur, dass es ja beim ersten Mal in Deinem Beispiel korrekt funktioniert. Du solltest diesen Fehler unbedingt im englischen Bug-Forum für MacOS melden.

Dieses abgeänderte Programm funktioniert unter MacOS auch beim zweiten Versuch, ein zweites Fenster zu öffnen und dort ein Popup-Menü zu öffen:
Code:
Enumeration FormMenu
  #PopupMenu_info
  #Menu_info_1
EndEnumeration

Procedure RefreshHandler()
  Shared Window_1.I
  DisplayPopupMenu(#PopupMenu_info, WindowID(Window_1))
EndProcedure
Procedure ButtonHandler()
  Window_2 = OpenWindow(#PB_Any, 100, 100, 500, 500, "Window_2", #PB_Window_SystemMenu)
  Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "DisplayPopup")
  BindGadgetEvent(Button, @RefreshHandler())
EndProcedure



Window_1 = OpenWindow(#PB_Any, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
CreatePopupMenu(#PopupMenu_info)
MenuItem(#Menu_info_1, "TEST")
Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "OpenWindow")
BindGadgetEvent(Button, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_CloseWindow
    CloseWindow(EventWindow())
  EndIf
Until Event = #PB_Event_CloseWindow And EventWindow() = Window_1

Autor:  kevv [ 07.05.2017 13:52 ]
Betreff des Beitrags:  Re: DisplayPopupMenu() unter mac

Das ist auch keine Lösung.
Jetzt wird das EventWindow() immer windows_1 zürückgeben
Code:

Enumeration FormMenu
  #PopupMenu_info
  #Menu_info_1
EndEnumeration

Procedure RefreshHandler()
  Shared Window_1.I
  DisplayPopupMenu(#PopupMenu_info, WindowID(Window_1))
;   DisplayPopupMenu(#PopupMenu_info, WindowID(EventWindow()))
EndProcedure
Procedure ButtonHandler()
  Window_2 = OpenWindow(#PB_Any, 100, 100, 500, 500, "Window_2", #PB_Window_SystemMenu)
  Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "DisplayPopup")
  BindGadgetEvent(Button, @RefreshHandler())
EndProcedure
Procedure menuHandler()
  Shared Window_1.I
 
  FensterEvent = EventWindow()
  If FensterEvent = Window_1
    Debug "DisplayPopup event in Window_1 ?"
  Else
    Debug "DisplayPopup event in Window: " + FensterEvent
  EndIf
EndProcedure


Window_1 = OpenWindow(#PB_Any, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
CreatePopupMenu(#PopupMenu_info)
MenuItem(#Menu_info_1, "TEST")
BindMenuEvent(#PopupMenu_info, #Menu_info_1, @menuHandler())

Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "OpenWindow")
BindGadgetEvent(Button, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_CloseWindow
    CloseWindow(EventWindow())
  EndIf
Until Event = #PB_Event_CloseWindow And EventWindow() = Window_1



Autor:  Shardik [ 07.05.2017 18:58 ]
Betreff des Beitrags:  Re: DisplayPopupMenu() unter mac

So funktioniert es plattform-unabhängig und zeigt das korrekte Fenster an, in dem das Popup-Menü angezeigt wird (mit Umgehung des Fehlers in MacOS):
Code:
Enumeration FormMenu
  #PopupMenu_info
  #Menu_info_1
EndEnumeration

Procedure RefreshHandler()
  Shared EventWindow.I

  EventWindow = EventWindow()

  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    Shared Window_1.I
    DisplayPopupMenu(#PopupMenu_info, WindowID(Window_1))
  CompilerElse
    DisplayPopupMenu(#PopupMenu_info, WindowID(EventWindow))
  CompilerEndIf
EndProcedure

Procedure ButtonHandler()
  Window_2 = OpenWindow(#PB_Any, 100, 100, 500, 500, "Window_2", #PB_Window_SystemMenu)
  Debug "Window_2 = " + Window_2
  Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "DisplayPopup")
  BindGadgetEvent(Button, @RefreshHandler())
EndProcedure

Procedure MenuHandler()
  Shared EventWindow.I
  Shared Window_1.I
 
  Debug "DisplayPopup event in Window: " + EventWindow
EndProcedure

Window_1 = OpenWindow(#PB_Any, 100, 100, 200, 90, "Click test", #PB_Window_SystemMenu)
Debug "Window_1 = " + Window_1
CreatePopupMenu(#PopupMenu_info)
MenuItem(#Menu_info_1, "TEST")
BindMenuEvent(#PopupMenu_info, #Menu_info_1, @MenuHandler())

Button = ButtonGadget(#PB_Any, 10, 10, 180, 30, "OpenWindow")
BindGadgetEvent(Button, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_CloseWindow
    CloseWindow(EventWindow())
  EndIf
Until Event = #PB_Event_CloseWindow And EventWindow() = Window_1

Autor:  kevv [ 10.05.2017 03:06 ]
Betreff des Beitrags:  Re: DisplayPopupMenu() unter mac

:allright:
Danke Shardik !

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/