Highlightable and selectable Array List (AKA: GuiListBoxCtrl) Questions
by Foestar · in Torque 3D Professional · 02/16/2011 (11:43 am) · 6 replies
Ok, so I'm not all that great with the GUI Components and I managed to create a list that will hold the players characters. I pretty much just used a GuiScrollCtrl and put a GuiListBoxCtrl in it. Then in a function I added my items when the GUI wakes. So for an example,
So what I want to do is add my array of saved characters in the box. But what I was having trouble implementing was a very visible selection window for this. I'm turning out to not be very good with GUI controls. So I just thought I'd ask to see if anyone has a working and very visible selection method for GuiListBoxCtrl's or any form of character selection for that matter. Right now I'm working towards the launch button not working unless an option is selected. But I'm not doing too well on checking to see if something in the list is selected.
function CharacterSelectDlg::onWake(%this) {
// Clean the list up before putting in that characters
Chars.clearItems();
// This is where I would add my items
// The first item added will be the option of creating a new player
Chars.addItem("Create Player");
}So what I want to do is add my array of saved characters in the box. But what I was having trouble implementing was a very visible selection window for this. I'm turning out to not be very good with GUI controls. So I just thought I'd ask to see if anyone has a working and very visible selection method for GuiListBoxCtrl's or any form of character selection for that matter. Right now I'm working towards the launch button not working unless an option is selected. But I'm not doing too well on checking to see if something in the list is selected.
About the author
Foestar Entertainment Biohazard Entertainment
#2
02/16/2011 (4:39 pm)
Yeah I realized that my code had a missing bracket and that was why my process didn't work. I think I got it now, thanks!
#3
Gonna keep messing around with it to try and fix it.
02/17/2011 (12:45 am)
Hmmm, I take back the part where I think I've got it. I did have a bracket missing. But it still doesn't work. It just seems likefontColorSEL fillColorSELdon't seem to work. In fact, I even tried putting in crazy bright colors and used the select method and it doesn't seem to do anything.
Gonna keep messing around with it to try and fix it.
#4
02/17/2011 (8:58 am)
Can you post your code for the gui control and your gui profile? Maybe more eyes on it will spot the problem. Also which version of T3D are you using?
#5
02/17/2011 (12:29 pm)
%guiContent = new GuiControl(CharacterSelectDlg) {
isContainer = "1";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "0 0";
Extent = "1024 768";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "1";
new GuiWindowCtrl() {
resizeWidth = "0";
resizeHeight = "0";
canMove = "1";
canClose = "0";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
EdgeSnap = "1";
text = "Character Selection";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "1";
Profile = "GuiWindowProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "259 209";
Extent = "498 360";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
//I had more code here, but it made my reply too long
//so I removed it since it was just Gui Buttons
new GuiScrollCtrl(CharactersScroll) {
willFirstRespond = "1";
hScrollBar = "alwaysOn";
vScrollBar = "alwaysOn";
lockHorizScroll = "0";
lockVertScroll = "0";
constantThumbHeight = "0";
childMargin = "0 0";
mouseWheelScrollSpeed = "-1";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "1";
Profile = "GuiScrollProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "149 80";
Extent = "200 200";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
new GuiListBoxCtrl(Chars) {
AllowMultipleSelections = "1";
fitParentWidth = "1";
isContainer = "0";
Profile = "GuiListBoxProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "1 1";
Extent = "185 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
};
};
};This is it to start with. I had to replace my gui with a backup because I messed it up hardcore last night trying to fix this and add something else. Again, I've tried adding a onSelect function and tried fontColorSEL and fillColorSEL several times but to no prevail. So I must be using it wrong in some way. Maybe the way I have the components set up?
#6
02/17/2011 (11:54 pm)
You could try GuiTextListCtrl instead. This works for me:new GuiTextListCtrl(lstInventory) {
columns = "0";
fitParentWidth = "1";
clipColumnText = "0";
position = "1 1";
extent = "132 2";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "InvList";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};singleton GuiControlProfile (InvList)
{
opaque = true;
fontType = "Arial";
fontSize = 16;
fontColor = "255 255 255";
fontColorHL = "255 255 0";
fontColorSEL = "0 0 0";
fillColor = "0 0 0";
fillColorSEL = "0 0 0";
justify = "left";
};
Torque Owner Ryan Mick
Red Witch Entertainment
// An item in the list is selected, causing the callback to occur GuiListBoxCtrl::onSelect(%this, %index, %itemText) { // Code to run whenever an item in the list is selected }Try calling the dump() method of your gui control to see what is available. Also the source code has a lot of documentation in it for this control.