|
1 registered members (AndrewAMD),
599
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: button in panel only works at pos(0,0)
[Re: Lukas]
#398650
04/05/12 00:13
04/05/12 00:13
|
Joined: Mar 2009
Posts: 20
atlee
OP
Newbie
|
OP
Newbie
Joined: Mar 2009
Posts: 20
|
This is the code that currently works for a single button:
BMAP* gpsfaset_bmp = "gpsfasetup.bmp"; BMAP* quitprogrambutt_bmp = "quitprogrambutt.bmp"; (The following BMAP* is for a second button) BMAP* runanalysisbutt_bmp = "runanalysisbutt.bmp";
PANEL* gpsfasetup_pan = { layer = 0; bmap = gpsfasetup_bmp; button(0,0,quitprogrambutt_bmp,NULL,NULL,quitprogram,NULL,NULL); flags = SHOW;
PANEL* quitprogrambutt_pan { pos_x = 220; pos_y = 550; layer = 10; bmap = quitprogrambutt_bmp; flags = SHOW;
function quitprogram() { sys_exit(NULL); }
The above code for one button works. But need to add more buttons.The button BMAP runanalysis_bmp needs to run the runanalysis function, for example. Thus, adding a additional button function would seem sensible:
button(0,0, runanalysisbutt_bmp,NULL,NULL,runanalysis,NULL,NULL;
PANEL* runanalysisbutt_pan; { pos_x = 80; pos_y = 550; layer = 10; bmap = runanalysis_bmp; flags = SHOW; }
This additional code does NOT work. The runanalysis button appears, but calls the quitprogam function, not the runanalysis function as coded. The quitprogram button works properly.
|
|
|
Re: button in panel only works at pos(0,0)
[Re: atlee]
#398655
04/05/12 06:56
04/05/12 06:56
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
Why you define 3 Panels? Try with my code, and if it is working, replace step by step my bitmaps with yours and then the code also.
#include <acknex.h>
#include <default.c>
PANEL* gpsfasetup_pan;
FONT* font_16 = "Arial#16";
BMAP* gpsfasetup_bmp = "#200x100x32";
BMAP* quitprogrambutt_bmp = "#30x30x32";
BMAP* runanalysisbutt_bmp = "#30x30x32";
void quitprogram()
{
pan_setdigits (gpsfasetup_pan,1,0,0,"BUTTON 1 WAS PRESSED",font_16,1,result);
}
void runanalysis()
{
pan_setdigits (gpsfasetup_pan,1,0,0,"BUTTON 2 WAS PRESSED",font_16,1,result);
}
void main()
{
video_mode = 6;
level_load (NULL);
wait(1);
bmap_fill (gpsfasetup_bmp,vector(150,150,150),100);
bmap_fill (quitprogrambutt_bmp,vector(0,0,255),50);
bmap_fill (runanalysisbutt_bmp,vector(255,0,0),50);
mouse_mode = 4;
}
PANEL* gpsfasetup_pan =
{
pos_x = 10;
pos_y = 10;
layer = 1;
bmap = gpsfasetup_bmp;
flags = SHOW;
button(10,30,quitprogrambutt_bmp,quitprogrambutt_bmp,quitprogrambutt_bmp,quitprogram,NULL,NULL);
button(100,30,runanalysisbutt_bmp,runanalysisbutt_bmp,runanalysisbutt_bmp,runanalysis,NULL,NULL;
digits (0,0,"NO BUTTON PRESSED",font_16,1,0);
}
Last edited by Widi; 04/05/12 06:59.
|
|
|
Re: button in panel only works at pos(0,0)
[Re: atlee]
#398657
04/05/12 07:59
04/05/12 07:59
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
PANEL* gpsfasetup_pan = { layer = 0; bmap = gpsfasetup_bmp; button(0,0,quitprogrambutt_bmp,NULL,NULL,quitprogram,NULL,NULL); flags = SHOW;
PANEL* quitprogrambutt_pan { pos_x = 220; pos_y = 550; layer = 10; bmap = quitprogrambutt_bmp; flags = SHOW;
i dont know if you made this mistake with your post text or also in your code but i think it would'nt have run if it were in your code but just mentioning:
PANEL* gpsfasetup_pan =
{
layer = 0;
bmap = gpsfasetup_bmp;
button(0,0,quitprogrambutt_bmp,NULL,NULL,quitprogram,NULL,NULL);
flags = SHOW;
}<- wheres this missing bracket
PANEL* quitprogrambutt_pan
{
pos_x = 220;
pos_y = 550;
layer = 10;
bmap = quitprogrambutt_bmp;
flags = SHOW;
}<- wheres this missing bracket
Compulsive compiler
|
|
|
Re: button in panel only works at pos(0,0)
[Re: atlee]
#398662
04/05/12 08:25
04/05/12 08:25
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay sorry for wasting space in your thread ,confirm widi's code workes on mine
Compulsive compiler
|
|
|
|