Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Moveable Panels #407878
09/20/12 13:15
09/20/12 13:15
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
I want to make a panel move if the user drags a button.
When the users clicks and holds a button and drags it, I want the panel to move along with the mouse!
How do I do that??

Thanks for your consideration


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Moveable Panels [Re: Yashas] #407880
09/20/12 13:35
09/20/12 13:35
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
in your panel make an event like this

Code:
function move_panel(PANEL* p)
{
   while(mouse_left) //Only run while the left button is held
   {
       p.pos_x = mouse_pos.x;
       p.pos.y = mouse_pos.y;
       wait(1);
   } 
}

PANEL* BLAH =
{
      event = move_panel;
}



That should work for ya


John C Leutz II

Re: Moveable Panels [Re: lostzac] #407884
09/20/12 13:52
09/20/12 13:52
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I would first calculate the offset from the panel to the mouse position and then move it just like lostzac said:

Code:
function move_panel(PANEL* p)
{
   VECTOR tempVec;
   vec_set(tempVec, p.pos_x);
   vec_sub(tempVec, mouse_pos.x);
   
   while(mouse_left) //Only run while the left button is held
   {
       p.pos_x = mouse_pos.x + tempVec.x;
       p.pos.y = mouse_pos.y + tempVec.y;
       wait(1);
   } 
}

PANEL* BLAH =
{
      event = move_panel;
}



POTATO-MAN saves the day! - Random
Re: Moveable Panels [Re: Kartoffel] #407886
09/20/12 13:59
09/20/12 13:59
Joined: Nov 2011
Posts: 139
India
Yashas Offline OP
Member
Yashas  Offline OP
Member

Joined: Nov 2011
Posts: 139
India
Thanks


Keep smiling laugh
http://translation.babylon.com/ - Translate many languages
Re: Moveable Panels [Re: Kartoffel] #407887
09/20/12 13:59
09/20/12 13:59
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
Originally Posted By: Kartoffel
I would first calculate the offset from the panel to the mouse position and then move it just like lostzac said:


Yeah that is a better way, slapping himself in the forehead for not thinking about it


John C Leutz II


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1