Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[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 Offline OP
Expert
Xarthor  Offline 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:
Code:
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: Xarthor] #258266
03/29/09 10:15
03/29/09 10:15
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I'm still stuck on this. Does nobody have an idea what I'm doing wrong?

Re: buttons don't highlight: pan_create -> ptr_remove -> pan_create [Re: Xarthor] #258272
03/29/09 12:20
03/29/09 12:20
Joined: Jun 2008
Posts: 151
Ukraine
XD1v0 Offline
Member
XD1v0  Offline
Member

Joined: Jun 2008
Posts: 151
Ukraine
Try copy empty string in pan_str
Code:
editor_list = txt_create(10,12);

str_cpy(pan_str,""); //copy empty string

int i;



A7 Commercial cool
Celeron 1700, GeForce 5500 FX 256mb, 1 Gb Ram
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 Offline
User
Shinobi  Offline
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.....
Quote:

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: Shinobi] #258345
03/29/09 20:27
03/29/09 20:27
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline OP
Expert
Xarthor  Offline OP
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
@XD1v0: Thank you very much! That did the trick. Although I don't understand this completely, because pan_str is a local string which should already be initialized. (see beginning of the function)

@shinobi: Thank you too! Thats indeed quite a nice function to know off, might come in handy in the future.

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 Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
POSSIBLY because you ar creating the strings badly for lite-c.
You really should be using
Code:
STRING* pan_str = str_create("");
STRING* editor_temp = str_create("");
at the start of your function and
Code:
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 Offline
User
Shinobi  Offline
User

Joined: Oct 2003
Posts: 560
Germany / NRW / Essen
Originally Posted By: Xarthor

@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


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