I’m a full newbie in ASOC and Xcode and I’m stuck with this “problem”:
I have an application’s window (bound as “mainWindow” outlet in the appDelegate) of which I want to get its origin coordinates.
Let’s say X0, Y0
Then I have a modal window (outlet = progressWindow) which contains a progress bar and a prompt.
I want that this progressWindow will display always at a fixed position relative to my mainWindow when called to display.
Let’s say (X1 = X0 + a) and (Y1 = Y0 + b)
First: How to retrieve X0 and Y0?
Second: how to move my “progressWindow” to (X1, Y1) requested position?
I found an example in ObjctiveC but I’m unable to translate in good ASOC, always get an error
Thank you in advance.
BTW, many thanks to the numerous posters on Macscripter from whom I took tools and tips to built my modest application.
You find the windows coordinates by asking for its frame() – this returns an NSRect, which gives you it’s origin (bottom-left x, y) and size (width, height). To move a window you can use one of several frame-related methods: setFrame:, setFrameOrigin:, setFrameDisplay: or setFrame:display:animate:.
Thank you Shane, I’m about to dig into the second part (moving window).
I just found a method, not sure it’s very elegant but doing the job, about retrieving X0 and Y0.
on giveMyFrame()-- the display dialog is for example
set dimsWin to mainWindow's frame as list
set dims2Win to (item 1 of dimsWin) as record
set XY to (origin of dims2Win as list)
set X0 to item 1 of XY as text
set Y0 to item 2 of XY as text
display dialog X0 & " - " & Y0
end giveMyFrame