Check if Window is hidden

Mac OSX specific forum
spacebuddy
Enthusiast
Enthusiast
Posts: 346
Joined: Thu Jul 02, 2009 5:42 am

Check if Window is hidden

Post by spacebuddy »

I know by using HideWIndow I can hide a window, but what call do I use to
find if the Window is hidden?

Thanks :)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Check if Window is hidden

Post by wilbert »

Does this help ?

Code: Select all

IsVisible = CocoaMessage(0, WindowID(0), "isVisible")
This should return if Window 0 is visible or not.
Windows (x64)
Raspberry Pi OS (Arm64)
spacebuddy
Enthusiast
Enthusiast
Posts: 346
Joined: Thu Jul 02, 2009 5:42 am

Re: Check if Window is hidden

Post by spacebuddy »

Works Perfect :D

Thanks
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: Check if Window is hidden

Post by mestnyi »

And for the gadget do not tell?
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Check if Window is hidden

Post by Shardik »

Code: Select all

IsVisible = CocoaMessage(0, GadgetID(0), "isHidden")
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Check if Window is hidden

Post by mk-soft »

Code: Select all

IsVisible = Bool(CocoaMessage(0, GadgetID(0), "isHidden") = 0)
:mrgreen:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Check if Window is hidden

Post by Shardik »

Sorry, should have been

Code: Select all

IsHidden = CocoaMessage(0, GadgetID(0), "isHidden")
A complete example:

Code: Select all

Define HiddenState.I

OpenWindow(0, 270, 100, 220, 95, "ButtonGadget demo")
ButtonGadget(0, 10, 20, 200, 25, "Hide button below")
ButtonGadget(1, 10, 55, 200, 25, "Visible button")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
        HiddenState ! 1
        HideGadget(1, HiddenState)
        
        If HiddenState 
          SetGadgetText(0, "Unhide button below")
        Else
          SetGadgetText(0, "Hide button below")
        EndIf

        Debug "Hidden state of 2nd button: " +
            CocoaMessage(0, GadgetID(1), "isHidden")
      EndIf
  EndSelect
ForEver
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Check if Window is hidden

Post by mk-soft »

I didn't mean that bad. Thank you very much for the example. :wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Check if Window is hidden

Post by Shardik »

mk-soft wrote:I didn't mean that bad.
I didn't assess your response as negative or bad. It was totally correct in modifing my incorrect example. Before posting I changed IsHidden to IsVisible and didn't take into account that true and false are switched. So I appreciated your correction... :wink:
Post Reply