Announcement

Collapse
No announcement yet.

How do I add event listener to a subcontrol on a list?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I add event listener to a subcontrol on a list?

    I'm using the code below to initialize some widgets in a movie. I'm concerned primarily with a list object I created that contains a sub-object button on the item renderer. I'm trying to add an event listener to the button (or series of buttons) in the future and I want to make sure I'm going down the right path. Basically I'm trying to add the event listener during the initialization process but keep coming up with "accessed none." The control is visible (so I know it's there) and it's named "button."


    Code:
    event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
    {
        local bool bWasHandled;
        bWasHandled = false;
    
        switch(WidgetName)
        {
            case ('list'):
                ListMC = GFxClikWidget(Widget);
                SetList(ListMC);
                UpdateListDataProvider();
                bWasHandled = true;
                break;
              
            case ('button'):
                PurchButton = GFxClikWidget(Widget);
                PurchButton.AddEventListener('CLIK_itemPress', OnListItemPress);
                bWasHandled = true;
                break;
    
            case ('menu'):
                MenuMC = Widget;
                bWasHandled = true;
                break;
    
            default:
                break;
        }
    
    	if (!bWasHandled)
    	{
    		bWasHandled = Super.WidgetInitialized(WidgetName, WidgetPath, Widget);
    	}
    
        return bWasHandled;
    }

    #2
    Figured it out finally. It wasn't working because I didn't bind the control in the default properties. This made it work and I can now create more custom ItemRenderers

    Code:
    SubWidgetBindings.Add((WidgetName="button",WidgetClass=class'GFxClikWidget'))

    Comment

    Working...
    X