It seems that in Xojo there is no way to monitor clicking on the window title bar. I wonder if using declares (in macOS) that can be possible.
Thanks.
Luciano
It seems that in Xojo there is no way to monitor clicking on the window title bar. I wonder if using declares (in macOS) that can be possible.
Thanks.
Luciano
There is some macOS Declares, but it makes the Titlebar transparent and therefore changes the appearance of the Window a little.
// put this in the Window.Opening event
Declare Sub setTitlebarAppearsTransparent Lib "Foundation" Selector "setTitlebarAppearsTransparent:" (WindowRef As Ptr, value As Boolean)
setTitlebarAppearsTransparent(Self.Handle, True)
Declare Sub setStyleMask Lib "Foundation" Selector "setStyleMask:" (WindowRef As Ptr, styleMask As UInt32)
setStyleMask(Self.Handle, 32783)
But once that is done, you can then use the Window’s MouseDown
event to track when the mouse has clicked within 28pts of the top edge of the window.
Note: I have added a DrawLine
in the Window’s Paint
event, to make the Titlebar appear semi-normal.
I hope this is useful in some way.
Why do you need this?
Thanks a lot Scot !!! It is a nice trick.
With respect to why I need this, is because I have made my own Snippets App (where info are encryoted/decrypred on-the-fly).
This app when is not used stay in the corner of my screen just as a WindowTitle bar (see screenshot).
To show all the snippets (that are stored in a Custom Canvas Controls, see screenshot):
I can’t call the window event ‘mouseEnter’ since there is no window but just the windowBar.
From here, the need of responding to click in the Window manubar.
Cool little app.
With the change to the title bar and styleMask I suggested, the MouseEnter event should also now work in the title bar area.
Of course, these changes may also affect the value of your Window height property (or if you’re using the Bounds property).
Haven’t tested that yet, though. Not at my desk.
If you have the MBS plugins you might be able to do it using NSEventMonitorMBS.