Is there a way to make a window lock in a position, or at least make it immovable once you position it? I am using a touchscreen and I need to be able to click on buttons without accidentaly moving the window. Also, is there a way to hide the top system menubar? Thanks so much.
You can use the following cocoa method to hide the menu bar (and dock). Note that if you click anywhere on screen that doesn’t belong to your app (i.e. on the desktop or in another app’s window) the menu will be visible again.
call method "setMenuBarVisible:" of class "NSMenu" with parameter false
There are two approaches to keeping a window from being dragged. The preferred approach, because it allows you to completely disable all dragging, is to create a borderless window (search for ‘nsborderlesswindowmask’ for more info). This would require drawing your window background manually, either by positioning imageviews or custom views strategically in the window background, because borderless windows are empty and draw nothing by default. While this approach is a bit more complex, the end result would be a completely un-draggable window.
The second approach, which can be accomplished easily in applescript, involves simply recording the window bounds before the window moves, and restoring it after it moves. This approach is significantly easier than the previous one, although the window remains draggable temporarily, and then snaps back to the initial position after the user lets up on the mouse button…
property windowBounds : {}
property dragDisabled : true
on clicked theObject
if name of theObject is "dragDisabled" then
set dragDisabled to (state of theObject) as boolean
end if
end clicked
on will move theObject --> Connect to the window
set windowBounds to bounds of theObject
end will move
on moved theObject --> Connect to the window
if dragDisabled then set bounds of theObject to windowBounds
end moved