Curl Global Community
How to know if Graphic object is being displayed? - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Discussions (https://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (https://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: How to know if Graphic object is being displayed? (/showthread.php?tid=323)



How to know if Graphic object is being displayed? - alchimiste - 10-25-2011

Hi,
I implement the function for getting data every 1 minute and showing a dialog on some conditions.
But this is somewhat annoying, because the dialog popups even if the graphic isn't acutally displayed on Monitor for some various reasons (for example it is hided by Curl or Windows OS).
So, I tried to show the dialog only if the graphic actually is displayed, but I couldn't do it.
How can I know if an graphic is actually displayed on Monitor screen?



RE: How to know if Graphic object is being displayed? - c-s - 10-25-2011

You could check View.visibility, perhaps?



RE: How to know if Graphic object is being displayed? - alchimiste - 10-27-2011

(10-25-2011, 02:07 PM)c-s Wrote: You could check View.visibility, perhaps?
I say, it's not only for View, but also all graphic.
For example, we can change screens by using Frame and it's add method.
Code:
{def frame = {Frame}}
{def child1 = {Frame "Child1"}}
{def child2 = {Frame "Child2"}}
{VBox
    frame,
    {HBox
        {CommandButton
            label="show child1",
            {on Action do
                {frame.add child1, replace?=true}
            }
        },
        {CommandButton
            label="show child2",
            {on Action do
                {frame.add child2, replace?=true}
            }
        }
    }
}

If we must check whether child1 is showed, how can we do it?
And I also want to know how to check if the browser or detached curl window is displayed actually.




RE: How to know if Graphic object is being displayed? - c-s - 10-27-2011

In that case, you should also look at the display-context option. As the documentation notes, when a Visual's display-context is non-null, it's attached to a graphical hierarchy or otherwise able to be displayed; if it's null, then you know it's definitely not being displayed. Able to be displayed doesn't necessary mean being displayed, so you would also want to check the View.visibility as mentioned above if the option is non-null if you're interested in seeing if it's really on-screen.

So, roughly:
  1. Is display-context null? If so, stop: we're not displayed.
  2. Else is get-view null? If so, again, stop: we're either being printed or not in an actual View.
  3. Else is View.visibility hidden or minimized? If so, stop: the View is out of the user's visibility.
Note that it's OK to check these values -- except note that if you're calling get-view that requires layout validation so be careful about when your timing -- but be cautious about moving Visuals around or setting key options in response to changes, or you may end up with invalidation loops or similar trouble.



RE: How to know if Graphic object is being displayed? - c-s - 10-27-2011

Kind of like this:

Code:
{curl 7.0, 8.0 applet}

{def frame = {Frame}}
{def child1 = {Frame "Child1"}}
{def child2 = {Frame "Child2"}}
{def td =
    {TextDisplay
        {on AttachEvent do
            {td.animate
                interval = 1s,
                {on TimerEvent do
                    {if child1.display-context == null then
                        set td.value = "not displayed"
                     else
                        {if-non-null v = {child1.get-view} then
                            {switch v.visibility
                             case "minimized", "hidden" do
                                set td.value = "not displayed"
                             else
                                set td.value = "displayed"
                                {dump {DateTime}, "displayed!"}
                            }
                         else
                            set td.value = "not displayed"
                        }
                    }
                }
            }
        }
    }
}

{VBox
    frame,
    {HBox
        {CommandButton
            label="show child1",
            {on Action do
                {frame.add child1, replace?=true}
            }
        },
        {CommandButton
            label="show child2",
            {on Action do
                {frame.add child2, replace?=true}
            }
        }
    },
    td
}

Note that if you minimize the browser window, the console will stop showing the displayed message.



RE: How to know if Graphic object is being displayed? - RobertShiplett - 11-05-2011

Can access to root frame be of use here?

{let root-fr:#Graphic = null}
|| some first graphic then declared with

{on ae:AttachEvent do
set root-fr = ae.root-frame

|| ?
(10-27-2011, 04:48 PM)c-s Wrote: Kind of like this: