Jump to content
Sign in to follow this  
Undeceived

Dialog - How to change picture / text by click in listbox item?

Recommended Posts

Hey guys, this is something I absolutely can't find a solution for. I saw some dialogs already which do it but I wasn't able to "extract" the method how it's done... :confused:

I have a listbox with a number of names in it. When I select one of these names, I want the picture of that person to appear in the picture dialog which is right next to the listbox. Then, when I select another person, the picture changes to the second person as well.

Beside that picture I want a small description text to appear in a text dialog but IIRC to change a picture and to change text is done by executing the same code - right?

Could you please help me with that? As I said, I saw some dialog systems doing it already, but they are in such a way too complex for me to understand how it's done...

This is why some really basic explanation to the point would be much appreciated.

Thanks a lot!! :)

Edited by Undeceived

Share this post


Link to post
Share on other sites

You need to use a ui eventhandler that is assigned to the listbox control.

That EH will call a function

In that function, take the LB selection, then use that data to update the rest of the controls on your dialog.

http://community.bistudio.com/wiki/User_Interface_Event_Handlers

http://community.bistudio.com/wiki/Category:Command_Group:_GUI_Control

Remember ui EH are destroyed when the dialog closes, use the onLoad event in your dialog to create the EH each time the dialog is opened.

Also remember to use:

http://community.bistudio.com/wiki/disableSerialization

At the top of your function, as you can not update ui components without running that command.

Share this post


Link to post
Share on other sites

Here you go, quick example I made. Hope it helps.

Download

Edit: Just noticed you wanted an actual LB, I used a combo control type rather than an actual LB. Same still applies though, since 1)combo is a sort of LB. 2) they share same commands.

Edited by Iceman77
Just noticed I used combo box instead of an actual LB.

Share this post


Link to post
Share on other sites

I usually use something in the control class, I think it's like,

onLBCurSelChanged = "[] spawn fnc_blablaCode;";

Share this post


Link to post
Share on other sites

Nice. Didn't realize you can do that. I usually use onLBCurSelChanged eventhandler for the specific control after I define it. But never in the actual control class.. Good to know!

Share this post


Link to post
Share on other sites

Hey guys,

thanks a lot for your answers!

Iceman, I'll check that example out - nevertheless I wrote you a PM. ;)

Share this post


Link to post
Share on other sites
Here you go, quick example I made. Hope it helps.

Download

Edit: Just noticed you wanted an actual LB, I used a combo control type rather than an actual LB. Same still applies though, since 1)combo is a sort of LB. 2) they share same commands.

thanks for that demo.. was pulling my hair out trying to get a pic to show up.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×