How to detect (break) when some window.top is changed?

Properly done you can make a shadowed property work

  1. make a new CLASS
  2. set its super to WINDOW
  3. in your class add a computed property for TOP
  4. in the GETTER put
            return Window(self).Top
  1. in the SETTER put
            Window(self).Top = value
  1. set the SUPER of the window you want tooth’s new class name
  2. put break points in the new class getter & setter

PROPERLY done most of the time you can get away with this kind of shadowing
Anything else can cause issues

Some things in the Xojo framework do NOT use the properties like you’d expect (like control locking doesnt set LEFT TOP HEIGHT or WIDTH - it seems to reach in behind the scenes) and there is no way shadowing like this can help
And, sadly, moving the window by dragging it doesnt set these properties either. But if you set TOP in code it does

go figure

2 Likes

If one needs to know when a window was dragged (or close to it), one way might be to save the top value and use a short timer to check if it changed…though that seems an expensive way to do it.

-Karen

Oh you can intercept some of the events & use that

Its just the underlying framework code seems to reach into the guts of the low level Window class and not use the properties that are exposed
So a computed wont see those change like you might surmise

filed a bug report as it shouldn’t be this way but …

Issue some changes to window properties (like top) are done magically behind the scenes

1 Like

File a feature request for a declarative UI architecture?

My usual way for many things is to check for change in the paint event… but that does not work (at least on my mac) for dragging a window.

So out of curiosity what event could one use to reliably detect a window being being dragged by the title bar?

Mouse Move, Enter, Exit events rely on the mouse being in the content area, which is not necessarily the case for that.

-Karen

Moved ?

LOL! Talk about obvious…

In all these years I never used that event, and was not even aware of it !!! (never needed it)

I just tried it and it fires with mouse up after the drag after Top has been changed.

  • Karen
1 Like

trust me your not the first to overlook something quite so obvious

doubt you’ll be that last either

1 Like

Back when the documentation was cleaner/better I’d go through a random class every now and then just to see what I’ve overlooked or forgotten. Easy enough to do since the framework is rather larger.

1 Like

Hack into the XOJWindow’s delegate class and override windowDidMove: You might be able to stack trace from there.

Yes it can be done in native Xojo with declare, a buttload of declares. I think it may be part of my AppKit, or if not, it does include a template for overriding these functions.