problem connecting variable with gui component

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

spark

New Member
Oct 28, 2005
18
0
0
Hi all,

I'm having problems populating a listbox with text. The log is giving me an "Accessed None" error. Here's the relevant code (I'm using the runtime version):

Code:
var GuiListBox MyList;

function FillList()
{
  MyList.List.Clear();
  MyList.List.Add("Foo");
}

function bool ButtonClick( GUIComponent Sender )
{
  Log "Button clicked!" );
  FillList();

  return True;
}

defaultproperties
{
  Begin Object class=GuiListBox Name=MyNewList
    bvisibleWhenEmpty=True
    //Winwidth,height,wintop=blahblahblah
  End Object
  Controls(4)=GuiListBox'MyNewList'
  MyList=MyNewList
}

The empty listbox shows up fine; when I click the button the log shows the "Button clicked!" message but immediately follows it with

ScriptWarning: GUIList Transient.GUIList9 (FunctionG UI.GUIListBase.Clear:001F) Accessed None
ScriptWarning: GUIList Transient.GUIList9 (Function GUI.GUIList.Add:0091) Accessed None

My guess is that somehow the variable isn't getting connected to the control in the MyList=MyNewList statement?
 

spark

New Member
Oct 28, 2005
18
0
0
Angel_Mapper said:
Just replace:

Controls(4)=GUIListBox'MyNewList'

with:

MyList=GUIListBox'MyNewList'

OK, did that, but now the listbox doesn't show up on the screen.

I've noticed the following behavior:

Code:
  local int foo;

  foo = MyList.ItemCount():
  Log( "Count is $foo" );   // log says foo is 0, so all's well

  MyList.List.Add( "item 1" );
  MyList.List.Add( "Item 2" );

  foo = MyList.ItemCount():
  Log( "Count is $foo" );  // log correctly says 2, so it's adding

So I guess stuff is being added to the listbox but it's not appearing onscreen. Additionally, the log also spits the "Accessed none" errors whenever I make the Add() call.

Is there some sort of refresh call that I'm forgetting?
 

spark

New Member
Oct 28, 2005
18
0
0
Angel_Mapper said:
Did you also get rid of the last line? (MyList=MyNewList) Forgot to mention that.

Yup, sure did. The listbox just vanished! ;-)
 

spark

New Member
Oct 28, 2005
18
0
0
Yeah, I actually copied the code from the Map Trader example from the beyondunreal wiki.

So I'm wondering how the listbox gets its display refreshed. If you call Add() and add a string does that automagically call some refresh function that displays the added text in the listbox or do you need to send some sort of state change message to something?
 

spark

New Member
Oct 28, 2005
18
0
0
Well, I finally got it to work. I used my code from the first post, minus the

Code:
  MyList = MyNewList;

part in the defaults section. However, I then added the following and everything worked:

Code:
function InitComponent( GuiController MyController, GUIComponent MyOwner )
{
	Super.Initcomponent( MyController, MyOwner);
	MyList = GuiListbox(Controls[4] );
}

So it looks like it really was a problem of connecting the variable MyList to the actual control. Weird, but it works. Thanks for the comments, tho!