Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (ozgur, TipmyPip, AndrewAMD), 1,209 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pointer in the button #370522
05/13/11 17:54
05/13/11 17:54
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Hi! Is there a way to create a pointer in the button? (I don't know if it's a pointer in this case) For exemple: I created a window in "PANEL" and a button like a icon bar, and the button function is move window. I used code bellow:
Code:
function MoveWindow(PANEL* _panel_sel){
	var click_offset[2];
	click_offset[0]=_panel_sel.pos_x - mouse_pos.x;
	click_offset[1]=_panel_sel.pos_y - mouse_pos.y;
	while(mouse_left==ON){
		proc_mode = PROC_EARLY;
		_panel_sel.pos_x = mouse_pos.x+click_offset[0];
		_panel_sel.pos_y = mouse_pos.y+click_offset[1];
		wait(1);
	}
}

PANEL* PanelTest={
        ...
        event = MoveWindow;
}


Okay, but there are many windows I'm going to create in the script. Is there a way to create a function to all buttons with the same function "MoveWindow()"?
If I put a event in panel, It work! But I wanted it to be in the button. Someone know?

Thanks guys!

Re: Pointer in the button [Re: Andre_Fernando] #370561
05/14/11 00:10
05/14/11 00:10
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I don't understand, can you describe your problem in different words?
Have you had a look at
button(x, y, bmapOn, bmapOff, bmapOver, functionOn, functionOff, functionOver);
already? FunctionOn can be replaced with your MoveWindow function if I understand you correctly.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Pointer in the button [Re: Superku] #370588
05/14/11 12:44
05/14/11 12:44
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
When I put the function "MoveWindow" in the "event" of the three panels, this works! Because the function recognizes the parameter when it's "Event". And if I put the function in button pops up an error E1513. Or I would have to create a MoveWindow for each panel button(MoveWindow1, MoveWindow2, MoveWindow3...), but I have more of the 30 panels. Is there only this way?

Re: Pointer in the button [Re: Andre_Fernando] #370589
05/14/11 12:55
05/14/11 12:55
Joined: Oct 2009
Posts: 149
Germany
M
muffel Offline
Member
muffel  Offline
Member
M

Joined: Oct 2009
Posts: 149
Germany
A button event function uses following parameters
param1 : number of the button ( 1st , 2nd ... button of a panel )
param2 : Pointer to the PANEL which the button is defined in

Look into the button page of the manual for more information

muffel

Re: Pointer in the button [Re: muffel] #370591
05/14/11 13:37
05/14/11 13:37
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
I don't understand, are you talking of the command "button_state"?

Re: Pointer in the button [Re: Andre_Fernando] #370617
05/14/11 17:41
05/14/11 17:41
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
As far as I understand the manual correctly, the event isn't meant for buttons at all.
Why are you not satisfied with the way how it works?
Do you want that the event only happens when clicking at a certain area of the panel?
Then you can compare the panel's position with the position of the mouse pointer and write a restriction in the event to a certain rectangle of the panel...

Re: Pointer in the button [Re: Pappenheimer] #370705
05/15/11 09:25
05/15/11 09:25
Joined: Oct 2009
Posts: 149
Germany
M
muffel Offline
Member
muffel  Offline
Member
M

Joined: Oct 2009
Posts: 149
Germany
You can pass a function of this type
function foo()
or of this type
function foo( var button , PANEL *pan )
to the button

But you pass a function of this type
function foo( PANEL *pan )
to the button.
Maybe this dont work.

muffel

Re: Pointer in the button [Re: muffel] #371034
05/17/11 13:25
05/17/11 13:25
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Originally Posted By: Pappenheimer
As far as I understand the manual correctly, the event isn't meant for buttons at all.
Why are you not satisfied with the way how it works?
Do you want that the event only happens when clicking at a certain area of the panel?
Then you can compare the panel's position with the position of the mouse pointer and write a restriction in the event to a certain rectangle of the panel...

I thought there was some easier way to create buttons for various functions with the same function. But it's true, I can create a function in a certain region of the window, I don't remembered of this. Thanks for help!


Originally Posted By: muffel
You can pass a function of this type
function foo()
or of this type
function foo( var button , PANEL *pan )
to the button

But you pass a function of this type
function foo( PANEL *pan )
to the button.
Maybe this dont work.

muffel

hey muffel, I did a workaround here and worked, but I want know the method that you showed me. Would code be so?
Code:
#include <acknex.h>
#include "default.c"

BMAP* PanelImage = "panel_image.png";
BMAP* ButtonImage = "button_image.png";

function MoveWindow(var button, PANEL* _panel_sel);

PANEL* PanelTest={
        layer=2;
        bmap=PanelImage;
        pos_x=50;pos_y=50;
        button(0,0,ButtonImage,ButtonImage,ButtonImage,MoveWindow,NULL,NULL);
}

function MoveWindow(var button, PANEL* _panel_sel){
	var click_offset[2];
	click_offset[0]=_panel_sel.pos_x - mouse_pos.x;
	click_offset[1]=_panel_sel.pos_y - mouse_pos.y;
	while(mouse_left==ON){
		proc_mode = PROC_EARLY;
		_panel_sel.pos_x = mouse_pos.x+click_offset[0];
		_panel_sel.pos_y = mouse_pos.y+click_offset[1];
		wait(1);
	}
}

function main(){
        ....
        wait(2);
        set(PanelTest,SHOW);
}


I did an test here, and it not worked. How Can I to associate the parameter button?
Thanks!


Moderated by  HeelX, rvL_eXile 

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