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
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 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
confine a dragged panel? #301239
12/09/09 05:30
12/09/09 05:30
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
How would I keep the panel from being dragged out of a specific bounding box. ie. if windowed, I don't want to drag it off screen or up too high over my static menu at the top.
I've tried adding " && sender.pos_x <= 600" to the while mouse_left loop, but if I drag really fast it will go past the bounding box and have to snap back... doesn't look good, I need it to be smooth and just stop at the edge of the predefined area.
I've also tried the same thing with mouse_cursor position, but nothing seems to work smoothly.
any ideas?


Black holes are where God divided by zero.
Re: confine a dragged panel? [Re: Nicholas] #301487
12/11/09 02:27
12/11/09 02:27
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
frown nobody has any ideas?


Black holes are where God divided by zero.
Re: confine a dragged panel? [Re: Nicholas] #301495
12/11/09 03:10
12/11/09 03:10
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
have you had a look at clamp(x, a, b)?

you just need to make sure it'll never reach the screen_size.x - pnl.size_x and same for y axis

Re: confine a dragged panel? [Re: MrGuest] #301506
12/11/09 08:18
12/11/09 08:18
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
Nevermind, I got it.
Code:
var max3=615;
var min2=0;
function DragPanel(PANEL* sender) // Simple function to drag a Panel.
{
        max3 = screen_size.x - sender.size_x;
	int startx = mouse_cursor.x - sender.pos_x;
	int starty = mouse_cursor.y - sender.pos_y;
	
	while(mouse_left)
	{
		if(sender.pos_x <= max3  &&  sender.pos_x >=min2)
		{
			sender.pos_x = mouse_cursor.x - startx;
			sender.pos_y = mouse_cursor.y - starty;
		}
		
		if(sender.pos_x >= max3) {sender.pos_x= max3;}
		if(sender.pos_x <= min2) {sender.pos_x= min2;}
		DropDown.pos_x = sender.pos_x + 5;	// Used for drop down menus
		DropDown.pos_y = sender.pos_y + 25;	// Used for drop down menus
		Controls.pos_x = DropDown.pos_x;		// Used for drop down menus
		Controls.pos_y = DropDown.pos_y;		// Used for drop down menus
		wait(1);
	}
	
}




thanks for the help, but I couldn't get clamp to work.. I suppose I could probably use that in there somewhere to clean up the min and max results.
I thought I'd post this to help anyone else.

Last edited by Nicholas; 12/11/09 08:21.

Black holes are where God divided by zero.

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