Page 1 of 1
Dragging windows with windowShape?
Posted: Mon Jan 06, 2014 3:37 pm
by thatkeith
I'm having lots of fun with windowShape – reminds me of the old RadWindow trick from back in the day. But I'm stumped over the (I hope) simple task of dragging the window.
How do I script the process of the user dragging the window around when it's in a custom windowShape and has no title bar?
(I've tried searching here, but it's a bit difficult when the forum won't let me search for "window"!

)
k
Re: Dragging windows with windowShape?
Posted: Mon Jan 06, 2014 4:22 pm
by FourthWorld
When making a custom window, you're making a truly custom window: you can have any controls you like, but you'll need to script their behaviors yourself.
The mouseMove message is an ideal way to handle mouse tracking on drags, but you'll have to keep a flag noting when the mouse is down and when it's not.
T?his may help, from a custom window I'm using in a new version of my devolution tool palette, which not only handles the dragging but also prevents dragging below the top visible bounds of the monitor (accounting for the menu bar on OS X and the top panel on Ubuntu and most other Linux distros) - just put this script in whatever graphic, button, or other object you're using for your drag region:
Code: Select all
local sDownDelta
on mouseDown
put the clickloc into sDownDelta
end mouseDown
on mouseMove
if sDownDelta is not empty then
put item 1 of the screenMouseLoc into x
put item 2 of the screenMouseLoc into y
switch the platform
case "MacOS"
put item 2 of the windowBoundingRect into tMinY
break
case "Linux"
put 24+ item 2 of the screenRect into tMinY
break
case "Win32"
put 0 into tMinY
end switch
put item 1 of the windowBoundingRect into tMinX
--
set the topleft of this stack to \
max(tMinX, (x-item 1 of sDownDelta)),\
max(tMinY, (y-item 2 of sDownDelta) )
end if
end mouseMove
on mouseRelease
put empty into sDownDelta
end mouseRelease
on mouseUp
put empty into sDownDelta
end mouseUp
Re: Dragging windows with windowShape?
Posted: Mon Jan 06, 2014 4:28 pm
by dunbarx
Try this in the card script:
Code: Select all
local tOffset
on mouseDown
put the mouseLoc into tOffset
end mouseDown
on mouseMove
put the loc of this stack into tScreen
put the mouseLoc into tMouse
set the loc of this stack to item 1 of tScreen + item 1 of tMouse - item 1 of tOffset & "," & item 2 of tScreen + item 2 of tMouse - item 2 of tOffset
end mouseMove
EDIT. Per Richard, I keep forgetting to go Modern. "MouseMove" is smoother than mouseStillDown
I originally placed this in the stack script.
Try it. It does not work, because neither "mousemove" nor "mouseStillDown" is received by the stack script handler. Why?
Craig Newman
Re: Dragging windows with windowShape?
Posted: Mon Jan 06, 2014 4:47 pm
by bn
Hi Keith,
a sample stack that shows some windowShape stuff including moving the stack around can be found here:
http://forums.runrev.com/phpBB2/viewtop ... =15#p82157
Kind regards
Bernd
Re: Dragging windows with windowShape?
Posted: Mon Jan 06, 2014 5:23 pm
by bn
Hi,
@Keith,
apparently Windows 7 and higher does not like the stack size to be larger than the skinning image, the non-skinned part shines through
http://forums.runrev.com/phpBB2/viewtop ... =9&t=18047
Kind regards
Bernd
Re: Dragging windows with windowShape?
Posted: Tue Jan 07, 2014 9:50 am
by thatkeith
@Richard, @Craig, @Bernd, thanks very much for the responses! This looks logical and useful, I'll give it a whirl as soon as I'm done with teaching today.
k