[Help] I'm a little stumped here...

EagleEye

31-01-2006 06:26:16

I am having trouble getting some combo boxes to work.

The problem is that the ListBoxTextItems are not being added to the damn combo boxes! I click the right side (the drop down arrow) of the top combo box (the only one I'm working with right now), and nothing happens. If I set the combo box to readonly=false, I can type in the combo box... hovering over the drop down arrow makes it light up... so internal events are working and reacting to keyboard and mouse stuff...

So why aren't these items being added to the list?

Posted below is the code, so feel free to take a look and tell me what I may be doing wrong.

The code has been messed around with a lot, so it's not all that optimized, so forgive me for that.

The window itself looks like this when it's created and shown:



(the font is too big, but ignore that)

The combo boxes are to the right of their labels as you can see.


Private WithEvents cmbClasses As Combobox
Private WithEvents cmbDisciplines As Combobox
Private WithEvents cmbSkills As Combobox
Private WithEvents cmbSpecializations As Combobox
Private WithEvents lblClasses As StaticText
Private WithEvents lblDisciplines As StaticText
Private WithEvents lblSkills As StaticText
Private WithEvents lblSpecializations As StaticText
Private WithEvents pbClassLevel As ProgressBar
Private WithEvents pbDisciplineLevel As ProgressBar
Private WithEvents pbSkillLevel As ProgressBar
Private WithEvents pbSpecializationLevel As ProgressBar
Private WithEvents TextWindow As StaticText
Private lbiClasses(6) As ListboxTextItem
Private lbiDisciplines(0) As ListboxTextItem
Private lbiSkills(0) As ListboxTextItem
Private lbiSpecializations(0) As ListboxTextItem
''' I will redim those zero arrays as needed

cmbClasses = WM.CreateCombobox(Combobox, Name)
cmbClasses.SetSize(cbSize)
cmbClasses.setReadOnly(True)
cmbClasses.SetPosition(rAlign, Y)
cmbClasses.SubscribeEvents()
''' Mywindow = the skills window...
MyWindow.AddChildWindow(cmbClasses)

lbiClasses(0) = New ListboxTextItem("Common", Convert.ToUInt32(VermundData.Vermund.Data.Classes.Common), IntPtr.Zero, False, False)
cmbClasses.addItem(lbiClasses(0))
lbiClasses(1) = New ListboxTextItem("Elementalist", Convert.ToUInt32(VermundData.Vermund.Data.Classes.Elementalist), IntPtr.Zero, False, False)
cmbClasses.addItem(lbiClasses(1))
lbiClasses(2) = New ListboxTextItem("Rogue", Convert.ToUInt32(VermundData.Vermund.Data.Classes.Rogue), IntPtr.Zero, False, True)
cmbClasses.addItem(lbiClasses(2))
lbiClasses(3) = New ListboxTextItem("Scholar", Convert.ToUInt32(VermundData.Vermund.Data.Classes.Scholar), IntPtr.Zero, False, True)
cmbClasses.addItem(lbiClasses(3))
lbiClasses(4) = New ListboxTextItem("Warrior", Convert.ToUInt32(VermundData.Vermund.Data.Classes.Warrior), IntPtr.Zero, False, True)
cmbClasses.addItem(lbiClasses(4))
lbiClasses(5) = New ListboxTextItem("Worker", Convert.ToUInt32(VermundData.Vermund.Data.Classes.Worker), IntPtr.Zero, False, True)
cmbClasses.addItem(lbiClasses(5))


That's about it... I only pasted the stuff relevant to the top combo box...

EagleEye

31-01-2006 06:31:41

FYI: I have WM set equal to WindowManager as sort of an alias...

alberts

31-01-2006 10:25:19

This code works for me:


class CEGUIApplication : ExampleApplication
{
protected OgreCEGUIRenderer mGuiRenderer = null;
protected GuiSystem mGuiSystem = null;
protected Window mBackgroundWindow = null;
protected Window mEditorWindow = null;
protected PushButton mQuitButton = null;
protected Editbox mEditbox = null;
protected Log mLog = null;
protected Combobox mComboBox = null;
protected ListboxTextItem mListboxTextItem1 = null;
protected ListboxTextItem mListboxTextItem2 = null;

protected override void CreateScene()
{
mLog = LogManager.Singleton.createLog("DemoCEGUI.log", false, false );
mLog.LogMessage("My new Log. Hells yeah!");

base.mSceneManager.AmbientLight = Color.FromArgb(125,125,125,125);
base.mSceneManager.SetSkyDome(true, "Examples/CloudySky", 5, 8);

mGuiRenderer = new OgreCEGUIRenderer( base.mRenderWindow );
mGuiRenderer.Initialise();
mGuiSystem = new GuiSystem(mGuiRenderer);

Logger.Instance.setLoggingLevel(LoggingLevel.Insane);

SchemeManager.Instance.LoadScheme("TaharezLook.scheme");
mGuiSystem.SetDefaultMouseCursor("TaharezLook", "MouseArrow");
mGuiSystem.DefaultFontName = "Tahoma-12";

mBackgroundWindow = WindowManager.Instance.CreateWindow("DefaultWindow", "BackgroundWindow");
mGuiSystem.GUISheet = mBackgroundWindow;

mEditorWindow = WindowManager.Instance.CreateWindow("TaharezLook/FrameWindow", "TestWindow");
mBackgroundWindow.AddChildWindow( mEditorWindow );
mEditorWindow.SetSize(0.9f, 0.9f);
mEditorWindow.SetPosition(0.05f, 0.05f);
mEditorWindow.Text = "CeguiDotNet Demo";
mEditorWindow.SubscribeEvents();

mQuitButton = WindowManager.Instance.CreatePushButton("TaharezLook/Button", "QuitButton");
mQuitButton.Text = "Quit";
mQuitButton.SetPosition(0.1f,0.1f);
mQuitButton.SetSize(0.8f,0.2f);
mQuitButton.SubscribeEvents();
mQuitButton.Clicked += new WindowEventDelegate(QuitClicked);
mEditorWindow.AddChildWindow(mQuitButton);

mEditbox = WindowManager.Instance.CreateEditbox("TaharezLook/Editbox", "Editbox");
mEditbox.Text = "Editbox";
mEditbox.SetPosition(0.1f, 0.4f);
mEditbox.SetSize(0.8f, 0.2f);
mEditbox.setReadOnly(false);
mEditbox.SubscribeEvents();
mEditorWindow.AddChildWindow(mEditbox);

mComboBox = WindowManager.Instance.CreateCombobox("TaharezLook/Combobox", "Combobox");
mComboBox.SetPosition(0.1f,0.6f);
mComboBox.SetSize(0.8f,0.2f);

mListboxTextItem1 = new ListboxTextItem("One",0,IntPtr.Zero,false,false);
mComboBox.addItem(mListboxTextItem1);

mListboxTextItem2 = new ListboxTextItem("Two",1,IntPtr.Zero,false,false);
mComboBox.addItem(mListboxTextItem2);

mComboBox.SubscribeEvents();
mEditorWindow.AddChildWindow(mComboBox);

mEditorWindow.Show();
}


Try incresing the height of the combobox (http://www.ogre3d.org/phpBB2/viewtopic.php?t=11074&highlight=listboxtextitem

rastaman

31-01-2006 13:02:01

are the indexes correct 0, 1, 2... 5 ?
add code to log the Convert.ToUInt32(VermundData.Vermund.Data.Classes.Common) and so on.

EagleEye

31-01-2006 14:38:37

I'll try your suggestions, thanks. :)

EagleEye

31-01-2006 20:15:21

Okay, that's the key right there.

The "height" of the box is the height of the entire thing, drop-down area included.

So I had it set to be the height of just the top part, so there was no room to drop down. I set it to a .8 relative height of the window, and sure 'nuff, it was .8 of the entire window when dropped down, but the TOP part was still the same size...

Undocumented feature I suppose... :)

I would think there would be a base height, and a drop-down list height... or you could set the drop down list to auto-resize based on the number of entries.

What I did was I created a small function to do approximately that:

Private Function ResizeBox(ByRef Mybox As Combobox)
If Convert.ToSingle(Mybox.getItemCount) < 8 Then
Mybox.setHeight(Convert.ToSingle(cmbClasses.getItemCount) * 0.1)
Else
Mybox.setHeight(0.8)
End If
End Function