Horizontal list of buttons/images (tab functionality) (1 Viewer)

GetWell

Portal Pro
October 4, 2006
205
32
Home Country
Denmark Denmark
Hio,

I am looking for a tab functionality, but can't find any way to do this.

There doesn't seem to be a tab control, so I tried to get the group (stacklayout) to work, but it can't add controls to it from codebehind?

xml:
<control>
<description></description>
<type>group</type>
<id>6</id>
<posX>298</posX>
<posY>50</posY>
<width>550</width>
<layout>StackLayout(2,Horizontal)</layout>
<visible>no</visible>
<animation effect="fade" time="1000">visiblechange</animation>
</control>

Codebehind:
[SkinControl(6)]
protected GUIGroup _Group;
GUIButtonControl btn = new GUIButtonControl(6);
btn.Label = "test";
_Group.AddControl(btn);

Do you have an idea of what I am doing wrong? Or do you have an idea for a better solution?

Thanks!
 

GetWell

Portal Pro
October 4, 2006
205
32
Home Country
Denmark Denmark
Are there really noone knowing how to create a dynamic horizontal button list?

I have a list of buttons which I want to display in a horizontal list, but can't find a smart way to do this in MP?
 

SilentException

Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    You don't define group in the code. You define buttons in the code then put them inside group in skin.

    Code:
    <control>
    	<description>...</description>
    	<type>group</type>
    	<posX>...</posX>
    	<posY>...</posY>
    	<layout>StackLayout(2, Horizontal)</layout>
    	<control>
    		<description>...</description>
    		<type>...</type>
    		<id>...</id>
    	</control>
    	<control>
    		...
    	</control>
    </control>
     

    GetWell

    Portal Pro
    October 4, 2006
    205
    32
    Home Country
    Denmark Denmark
    thats what I'm trying, but I can't get the codebehind to work. Do you have an example?
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    [SkinControlAttribute(6)]
    protected GUIButtonControl btn1 = new null
    [SkinControlAttribute(7)]
    protected GUIButtonControl btn2 = new null
    ...
    [SkinControlAttribute(N)]
    protected GUIButtonControl btnN = new null
     

    GetWell

    Portal Pro
    October 4, 2006
    205
    32
    Home Country
    Denmark Denmark
    maybe I am not explaining me correctly.

    I don't know how many buttons I need to show from the start. It changes all the time because I will use it with the NotificationBar
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    In that case, your first bit of skin/code looks OK. Not sure what could be wrong yet. It might be because you don't set visible = true on group? :)
     

    GetWell

    Portal Pro
    October 4, 2006
    205
    32
    Home Country
    Denmark Denmark
    hmm I get a Object not set to an instance of an object error.

    I have tried to search MP source code for an example, but it seems that noone tries to access it this way.

    Can it be the [SkinControl] that does not instanciate correctly?
     

    SilentException

    Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    Not sure, you can try to use SkinControlAttribute instead.

    Other try is to loose SkinControl and group alltogether and make a property that will get group control directly from the skin:

    Code:
    protected GUIGroup _mainGroup = null
    protected GUIGroup MainGroup
    {
      get
      {
        if (_mainGroup == null)
          _mainGroup = GetControl(groupID) as GUIGroup;
        return _mainGroup;
      }
    }
    ...
    ...
    
    MainGroup.Add(button1)...
     

    GetWell

    Portal Pro
    October 4, 2006
    205
    32
    Home Country
    Denmark Denmark
    still no luck :-(

    this is really weird. I have tried to put in a dummy control and can see it in MP, but I can't reach it.

    I have also tried without GetWindow()
    Codebehind:
    PHP:
    protected GUIGroup _Group;
            protected GUIGroup MainGroup
            {
                get
                {
                    if (_Group == null)
                        _Group = GUIWindowManager.GetWindow(99207).GetControl(6) as GUIGroup;
                    return _Group;
                }
            }
    
    ...
    ...
    
    GUIButtonControl btn = new GUIButtonControl(6);
    MainGroup.AddControl(btn);

    XML
    PHP:
    <control>
          <description></description>
          <type>group</type>
          <id>6</id>
          <posX>10</posX>
          <posY>10</posY>
          <width>550</width>
          <layout>StackLayout(2,Horizontal)</layout>
          <visible>yes</visible>
          <animation effect="fade" time="1000">visiblechange</animation>
          <control>
            <type>image</type>
            <texture>notificationbar/button_background_focus.png</texture>
            <id>101</id>
            <posX>10</posX>
            <posY>10</posY>
            <width>50</width>
            <height>40</height>
          </control>
        </control>
     

    Users who are viewing this thread

    Top Bottom