Page 1 of 1

MacOS "superview"

Posted: Sun Dec 02, 2018 5:31 pm
by mk-soft
The gadgets have no superview if they are in a second item of a PanelGadget.

Maybe you forgot to set this internally when creating the gadgets?

Code: Select all

If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  PanelGadget     (0, 8, 8, 306, 203)
  AddGadgetItem (0, -1, "Panel 1")
  PanelGadget (1, 5, 5, 290, 166)
  AddGadgetItem(1, -1, "Sub-Panel 1")
  AddGadgetItem(1, -1, "Sub-Panel 2")
  AddGadgetItem(1, -1, "Sub-Panel 3")
  CloseGadgetList()
  AddGadgetItem (0, -1,"Panel 2")
  ButtonGadget(2, 10, 15, 80, 24,"Button 1")
  ButtonGadget(3, 95, 15, 80, 24,"Button 2")
  CloseGadgetList()
  
  Debug "Panel = " + GadgetID(0)
  Debug "Panel 1 = " + GadgetID(1)
  Debug "Button 2 = " + GadgetID(2)
  
  sv = CocoaMessage(0, GadgetID(1), "superview")
  sv = CocoaMessage(0, sv, "superview")
  Debug "Parent from Panel 1 = " + sv
  
  sv = CocoaMessage(0, GadgetID(2), "superview")
  sv = CocoaMessage(0, sv, "superview")
  Debug "Parent from Gadget 2 = " + sv
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
[/size]

Re: MacOS "superview"

Posted: Mon Dec 10, 2018 10:45 pm
by mk-soft
I think is not a Bug...

PB
PanelGadget -> AddItems -> Gadgets

OSX
TabView -> TabViewItems -> View -> (gadgets)
Problem is that the "View" have not a method to parent object.

Perhaps anyone habe a solution for me...

Please move to Code questions...

Re: MacOS "superview"

Posted: Tue Dec 11, 2018 8:08 am
by wilbert
I looked at it but unfortunately didn’t find an answer to the problem. :?

Re: MacOS "superview"

Posted: Tue Dec 11, 2018 4:24 pm
by mk-soft
wilbert wrote:I looked at it but unfortunately didn’t find an answer to the problem. :?
I've searched several forums.
Here you can only use the forward approach to search all TabViewControllers until you have found the right one.

Re: MacOS "superview"

Posted: Mon Jan 07, 2019 3:54 pm
by mestnyi

Code: Select all

If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  PanelGadget     (0, 8, 8, 306, 203)
  AddGadgetItem (0, -1, "Panel 1")
  PanelGadget (1, 5, 5, 290, 166)
  AddGadgetItem(1, -1, "Sub-Panel 1")
  AddGadgetItem(1, -1, "Sub-Panel 2")
  AddGadgetItem(1, -1, "Sub-Panel 3")
  CloseGadgetList()
  AddGadgetItem (0, -1,"Panel 2")
  ButtonGadget(2, 10, 15, 80, 24,"Button 1")
  ButtonGadget(3, 95, 15, 80, 24,"Button 2")
  CloseGadgetList()
  
  Debug "Panel = " + GadgetID(0)
  Debug "Panel 1 = " + GadgetID(1)
  Debug "Button 2 = " + GadgetID(2)
  
  sv = CocoaMessage(0, GadgetID(1), "superview")
  sv = CocoaMessage(0, sv, "superview")
  Debug "Parent from Panel 1 = " + sv
  
  SetGadgetState(0, 1)
  sv = CocoaMessage(0, GadgetID(2), "superview")
  sv = CocoaMessage(0, sv, "superview")
  Debug "Parent from Gadget 2 = " + sv
  SetGadgetState(0, 0)
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
This is how it works. :)

Re: MacOS "superview"

Posted: Mon Jan 07, 2019 8:58 pm
by mk-soft
However, this does not help if you are looking for the parent gadget for any gadget.
So we know that with the PanelGadget the active item only has a superview.

That's why in the forum for Objectiv-C you can only find the solution to find the right parent by searching all PanelGadgets forward.