Alternative Drag Bar

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Alternative Drag Bar

Post by richmond62 » Wed Oct 11, 2023 9:18 am

Screen Shot 2023-10-11 at 11.15.33.png
-
I want to be able to drag my stack around the screen by click-dragging on the brown graphic at the bottom of the stack . . .

But this:

Code: Select all

on mouseDown
   grab me
end mouseDown

on mouseMove
   set the bottomleft of stack "edge drag" to the bottomleft of me
end mouseMove
Screws up badly:

1. obviously being called far too often as there is major screen flicker.

2. the graphic ends up off-screen.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Alternative Drag Bar

Post by richmond62 » Wed Oct 11, 2023 9:27 am

And this is equally useless:

Code: Select all

on mouseDown
   grab me
end mouseDown

on mouseMove
   put item 1 of the location of stack "edge drag" into LR
   put item 2 of the location of stack "edge drag" into UD
   set the left of stack "edge drag" to (LR - (the left of me))
   set the bottom of stack "edge drag" to (UD + (the bottom of me))
end mouseMove
as the graphic ends up being ungrabbable and the stack jinks around the screen for no obvious reason.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Alternative Drag Bar

Post by richmond62 » Wed Oct 11, 2023 1:33 pm

The problem with this:

Code: Select all

on mouseMove
if the mouse is down then set the loc of this stack to the screenMouseLoc
end mouseMove
is that it results in the 'drag bar' graphic being moved to the middle of the stack when it should remain at the bottom:

BEFORE
-
Screen Shot 2023-10-11 at 15.30.55.png
-

AFTER
-
Screen Shot 2023-10-11 at 15.31.53.png

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Alternative Drag Bar

Post by Klaus » Wed Oct 11, 2023 1:52 pm

Hi richmond,

put this into the script of your graphic:

Code: Select all

local maydrag

on mouseDown
   put mouseH() & "," & mouseV() into maydrag
end mouseDown

on mouseMove x,y
   if maydrag is empty then 
      exit mousemove
   end if
   set the topLeft of this stack to (item 1 of the screenMouseLoc - item 1 of maydrag), (item 2 of the screenMouseLoc - item 2 of maydrag)
end mouseMove

on mouseUp
   put empty into maydrag
end mouseUp

on mouserelease
  mouseup
end mouserelease
Best

Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10095
Joined: Fri Feb 19, 2010 10:17 am

Re: Alternative Drag Bar

Post by richmond62 » Wed Oct 11, 2023 2:05 pm

You are still 'The man' Klaus!

Post Reply