Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Sep 19, 2019 4:03 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Move a control at runtime
PostPosted: Thu Feb 04, 2010 1:32 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
If you want move a window, canvas, textfield, ect. at runtime then you can use the code below.
Add two global integer variables saveX and saveY.
MouseDown:
saveX = x
saveY = y
return true

MouseDrag:
me.left = me.left + x - saveX
me.top = me.top + y - saveY


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 1:59 pm 
Offline

Joined: Fri Feb 27, 2009 12:18 am
Posts: 54
thanks for the code serd83,

but i dont have a mousedrag event !

not sure why though


Russ


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 2:07 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
EditFields do not expose the MouseDrag event, probably because it is used internally for highlighting text. But you should still get MouseMove events, where you can test for System.MouseDown.


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 2:08 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 3:53 pm
Posts: 3261
Location: England
Some controls have MouseDrag events, including Canvas, GroupBox, Line, ListBox, Oval, Placard, ProgressBar, Rectangle, RoundRectangle, Scrollbar, Slider, StaticText, TabPanel

So do Windows.

But several controls do not.

_________________
Steve Garman
Using REALbasic 2008r2 Professional on Windows Vista Ultimate
and REALbasic 2009r5.1 Professional on Linux Ubuntu 9.04 Desktop
and REAL Studio 2010r1 Personal on Linux Ubuntu 9.10 Desktop
Occasional blog


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 2:17 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
Sorry, I write the code here and think not about that. :)
Another solution to Tim's suggestion is to add a canvas over the textfield. Then you should use the code instead in the textfield here:
Canvas.MouseDown:
saveX = x
saveY = y
return true

Canvas.MouseDrag:
editfield1.left = editfield1.left + x - saveX
editfield1.top = editfield1.top + y - saveY


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 2:46 pm 
Offline

Joined: Fri Feb 27, 2009 12:18 am
Posts: 54
hi timhare,

i have the following code in my mousemove event but nothing happens, it doesnt seem to see the system.mousedown
have i mistook the concept here?

if system.MouseDown then
app.MouseCursor = system.Cursors.ArrowAllDirections

me.left = me.left + x - ofsetX
me.top = me.top + y - ofsetY

end if


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 3:01 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
In MouseDown use this:
ofsetX = x
ofsetY = y

MouseMove:
if system.mousedown = true then
me.left = me.left + x - ofsetX
me.top = me.top + y - ofsetY
end


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 3:46 pm 
Offline

Joined: Fri Feb 27, 2009 12:18 am
Posts: 54
tried that, makes no difference, it doesnt move

;-(

Russ


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 5:55 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
It works here.


Top
 Profile  
Reply with quote  
 Post subject: Re: Move a control at runtime
PostPosted: Thu Feb 04, 2010 11:20 pm 
Offline

Joined: Thu Feb 22, 2007 7:08 pm
Posts: 1384
Have you remove "return true" from MouseDown?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group