2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
[solved] buttons don't highlight
#258127
03/27/09 20:37
03/27/09 20:37
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
OP
Expert
|
OP
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
Hi. What I'm doing is: - creating a list of buttons dynamically To do so I have a panel pointer globally defined which I'll assign a panel to through pan_create. So far it works fine in the first run. Now I have another function that unloads that list and removes all pointers of the strings (used as labels for the buttons), a text object and the panel object. If I know "re-create" the list everything looks fine again BUT the panel's buttons do not react on mouse over. However they react if I click them. I used the search but couldn't come up with a topic that covers this. If there is one, please point me to it. Here is the code that might be of interest:
FONT* arial_16 = "Arial#16";
TEXT* editor_list;
PANEL* editor_listpan;
void editor_ShowList(TEXT* _txt,_lines)
{
STRING* pan_str = "";
STRING* editor_temp = "";
editor_StatusList = 1;
if(_lines > 10)
{
_lines = 10;
}
editor_list = txt_create(10,12);
int i;
for(i=0; i<_lines; i++)
{
if((editor_list.pstring)[i])
{
str_cpy((editor_list.pstring)[i],(_txt.pstring)[i]);
str_for_num(editor_temp,16*i+20);
str_cat(pan_str,"button(5,");
str_cat(pan_str,editor_temp);
str_cat(pan_str,",btn_Small2,btn_Small1,btn_Small2,NULL,NULL,NULL;");
}
}
str_cat(pan_str,"button(393,1,btn_close2,btn_close1,btn_close2,editor_exitList,NULL,NULL);");
editor_listpan = pan_create(pan_str,10);
editor_listpan.red = 128;
editor_listpan.green = 128;
editor_listpan.blue = 128;
editor_listpan.size_x = 410;
editor_listpan.size_y = 25 + _lines*16;
editor_listpan.pos_x = (screen_size.x - editor_listpan.size_x) / 2;
editor_listpan.pos_y = 150;
editor_list.pos_x = editor_listpan.pos_x + 10;
editor_list.pos_y = editor_listpan.pos_y + 20;
editor_list.font = arial_16;
set(editor_listpan,SHOW|LIGHT);
set(editor_list,SHOW);
}
void editor_unloadList()
{
int i;
reset(editor_list,SHOW);
reset(editor_listpan,SHOW);
for(i=0; i<editor_list.strings; i++)
{
if((editor_list.pstring)[i])
{
ptr_remove((editor_list.pstring)[i]);
}
}
ptr_remove(editor_list);
ptr_remove(editor_listpan);
}
Thanks for any ideas! ps: uncommenting the ptr_remove(editor_listpan); line doesn't affect that whole misbehaviour at all.
Last edited by Xarthor; 03/29/09 20:27.
|
|
|
Re: buttons don't highlight: pan_create -> ptr_remove -> pan_create
[Re: XD1v0]
#258277
03/29/09 12:29
03/29/09 12:29
|
Joined: Oct 2003
Posts: 560 Germany / NRW / Essen
Shinobi
User
|
User
Joined: Oct 2003
Posts: 560
Germany / NRW / Essen
|
use "pan_setbutton" that way you can add buttons as mutch as you like. And the same way you can change Button Bmap´s and more. I dont know if it helps but you can try..... Parameters:PANEL* Panel pointer. num Number of an existing button (1 = first button of the panel), or 0 for adding a new button to the panel. type Type of the button, 1 = push, 2 = toggle, 3 = radio. x, y, ... Button parameters to be set - see button.
Returns: Number of the button, or 0 if the button could not be found or created. Example: BMAP* clicked_pcx = "clicked.pcx"; BMAP* over_pcx = "over.pcx"; BMAP* normal_pcx = "normal.pcx";
PANEL* main_pan = { bmap = "main.pcx"; flags = SHOW; }
function exit_program() { sys_exit(NULL); }
function main() { mouse_mode = 4; // activate mouse pan_setbutton(main_pan,0,1, // set a new push button for quitting the game 150,130,clicked_pcx,normal_pcx,over_pcx,NULL,exit_program,NULL,NULL); }
Last edited by Shinobi; 03/29/09 12:31.
|
|
|
Re: buttons don't highlight: pan_create -> ptr_remove -> pan_create
[Re: Xarthor]
#258369
03/30/09 03:12
03/30/09 03:12
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
POSSIBLY because you ar creating the strings badly for lite-c. You really should be using STRING* pan_str = str_create("");
STRING* editor_temp = str_create(""); at the start of your function and str_remove(pan_str);
str_remove(editor_temp; at the end to release the allocated space.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: buttons don't highlight: pan_create -> ptr_remove -> pan_create
[Re: Xarthor]
#258390
03/30/09 09:51
03/30/09 09:51
|
Joined: Oct 2003
Posts: 560 Germany / NRW / Essen
Shinobi
User
|
User
Joined: Oct 2003
Posts: 560
Germany / NRW / Essen
|
@shinobi: Thank you too! Thats indeed quite a nice function to know off, might come in handy in the future.
your welcome and dont forget the other nice and handy new commands like: pan_setdigits pan_setneedle pan_setslider pan_setwindow pan_setpos pan_setvar
|
|
|
|