Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/Window Selection
Required plugins for this example: MBS MacBase Plugin, MBS MacFrameworks Plugin, MBS Main Plugin, MBS Overlay Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/Window Selection
This example is the version from Sun, 10th Dec 2016.
Project "Window Selection.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() SelectAWindow End EventHandler
Sub GotAWindow(WindowNumber as integer, X as integer, Y as integer, Width as Integer, Height as Integer, TargetInfo as Dictionary) app.FrontmostMBS = True MsgBox "You selected: "+str(WindowNumber)+" at "+str(x)+"/"+str(y)+" "+str(Width)+" "+str(Height)+" with title: "+TargetInfo.Value(CGWindowMBS.kCGWindowName) End Sub
Sub SelectAWindow() t = new MyTimer t.mode = 2 t.Period = 500 End Sub
Property t As MyTimer
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyTimer Inherits Timer
EventHandler Sub Action() dim x as integer = System.Mousex dim y as integer = screen(0).Height-System.Mousey dim belowWindowNumber as integer = 0 if o<>Nil then belowWindowNumber = o.WindowID end if dim windowNumber as integer = NSWindowMBS.windowNumberAtPoint(x,y, belowWindowNumber) if LastWindowNumber = windowNumber then Return LastWindowNumber = windowNumber dim list() as Dictionary = CGWindowMBS.GetWindowListInfo(CGWindowMBS.kCGWindowListOptionIncludingWindow, windowNumber) if UBound(list) <0 then Return dim w as Dictionary = list(0) dim bounds as Dictionary = w.Value(CGWindowMBS.kCGWindowBounds) dim wx as integer = bounds.Value("X") dim wy as integer = bounds.Value("Y") dim wh as integer = bounds.Value("height") dim ww as integer = bounds.Value("width") dim p as Picture = new Picture(ww,wh,32) dim m as Picture = new Picture(ww,wh,32) p.Graphics.forecolor = &cFFFFFF p.graphics.FillRect 0, 0, p.Width, p.Height m.Graphics.forecolor = &c777777 m.graphics.FillRect 0, 0, m.Width, m.Height p.Graphics.forecolor = &cFF0000 p.Graphics.PenWidth = 3 p.Graphics.PenHeight = 3 p.graphics.drawrect 0, 0, p.Width, p.Height o=new MyOverlayMBS(wx,wy,ww,wh) o.Pict=p o.Mask=m o.UpdateShow o.TargetWindowNumber = windowNumber o.TargetInfo = list(0) o.IgnoreMouseClicks = false End EventHandler
Property LastWindowNumber As Integer
Property o As MyOverlayMBS
End Class
Class MyOverlayMBS Inherits OverlayMBS
EventHandler Function MouseDown(x as integer, y as integer, modifiers as integer) As boolean Return true End EventHandler
EventHandler Function MouseUp(x as integer, y as integer, modifiers as integer) As boolean app.t.Mode = 0 app.t = nil me.hide app.GotAWindow TargetWindowNumber, me.left, me.top, me.Width, me.Height, TargetInfo Return true End EventHandler
Property TargetInfo As Dictionary
Property TargetWindowNumber As Integer
Property timer As MyTimer
End Class
Module Module1
End Module
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.

MBS Xojo Chart Plugins