Pointer in the button

Posted By: Andre_Fernando

Pointer in the button - 05/13/11 17:54

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!
Posted By: Superku

Re: Pointer in the button - 05/14/11 00:10

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.
Posted By: Andre_Fernando

Re: Pointer in the button - 05/14/11 12:44

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?
Posted By: muffel

Re: Pointer in the button - 05/14/11 12:55

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
Posted By: Andre_Fernando

Re: Pointer in the button - 05/14/11 13:37

I don't understand, are you talking of the command "button_state"?
Posted By: Pappenheimer

Re: Pointer in the button - 05/14/11 17:41

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...
Posted By: muffel

Re: Pointer in the button - 05/15/11 09:25

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
Posted By: Andre_Fernando

Re: Pointer in the button - 05/17/11 13:25

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!
© 2024 lite-C Forums