Results 1 to 6 of 6

Thread: [Bug/Suggestion? Not sure] GetAttribute/SetAttribute API Call

  1. #1
    Basic Member zedor's Avatar
    Join Date
    Jun 2013
    Posts
    39

    [Bug/Suggestion? Not sure] GetAttribute/SetAttribute API Call

    What's the intended behaviour for these?
    Code:
    GetAttributeInt	Panel.GetAttributeInt( cstring cstring_1, integer integer_2 )	
    GetAttributeString	Panel.GetAttributeString( cstring cstring_1, cstring cstring_2 )	
    GetAttributeUInt32	Panel.GetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )	
    SetAttributeInt	Panel.SetAttributeInt( cstring cstring_1, integer integer_2 )	
    SetAttributeString	Panel.SetAttributeString( cstring cstring_1, cstring cstring_2 )	
    SetAttributeUInt32	Panel.SetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )
    It seems to be separate from 'default' properties/attributes. I can SetAttribute 'text' to something, and GetAttribute properly returns what I set, but the text itself is unchanged.
    If that is not the intended behaviour, then I guess a fix is expected, but if it is, it would be nice to get the ability to change default props/atts like 'text', 'placeholder', etc.

  2. #2
    Basic Member
    Join Date
    Jun 2015
    Posts
    7
    The GetAttribute*/SetAttribute* functions seem to be a way to just keep internal state for an element. But their names' are deceiving when in the context of XML. By the name of these functions, it would make sense that they would set an attribute (as in the element) for the given panel, instead they set internal state. While this is useful, it still doesn't provide a way to set an actual attribute on an element other than the ones that are supported by the element (text, maxchars, etc.)

  3. #3
    Basic Member
    Join Date
    Jun 2015
    Posts
    9
    Quote Originally Posted by zedor View Post
    What's the intended behaviour for these?
    Code:
    GetAttributeInt	Panel.GetAttributeInt( cstring cstring_1, integer integer_2 )	
    GetAttributeString	Panel.GetAttributeString( cstring cstring_1, cstring cstring_2 )	
    GetAttributeUInt32	Panel.GetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )	
    SetAttributeInt	Panel.SetAttributeInt( cstring cstring_1, integer integer_2 )	
    SetAttributeString	Panel.SetAttributeString( cstring cstring_1, cstring cstring_2 )	
    SetAttributeUInt32	Panel.SetAttributeUInt32( cstring cstring_1, unsigned unsigned_2 )
    It seems to be separate from 'default' properties/attributes. I can SetAttribute 'text' to something, and GetAttribute properly returns what I set, but the text itself is unchanged.
    If that is not the intended behaviour, then I guess a fix is expected, but if it is, it would be nice to get the ability to change default props/atts like 'text', 'placeholder', etc.
    A good example use of this at the moment is to pass values to loaded elements. E.g:

    Code:
    for (var playerId of Game.GetAllPlayerIDs()) {
      var playerInfo = Game.GetPlayerInfo(playerId);
      if (playerInfo["player_team_id"] === teamId) {
        var playerPanel = $.CreatePanel("Panel", playersPanel, "player" + playerId);
        playerPanel.SetAttributeInt("id", playerId);
        playerPanel.SetAttributeString("steamId", playerInfo["player_steamid"]);
        playerPanel.BLoadLayout("file://{resources}/layout/custom_game/draft/player.xml", false, false);
      }
    }
    player.xml can then load the attributes and act as a modularized component, with many loaded, each with different behaviour (in this case, one per player).

  4. #4
    Basic Member zedor's Avatar
    Join Date
    Jun 2013
    Posts
    39
    Yep, but that's not really what this topic is about

  5. #5
    Basic Member
    Join Date
    Jun 2015
    Posts
    9
    Quote Originally Posted by zedor View Post
    Yep, but that's not really what this topic is about
    Your post appeared to be expecting SetAttribute() to modify the elements, I was giving what I assume is the intended use - what you are talking about is something we'd want alongside the Get/SetAttribute() functionality (which is useful as it stands, as shown above).

    Given there are different types for the types of element in JS, it would seem odd (to me) to have a generic function passing in a name - instead just have attributes on the object to represent those on the element, and set them directly - that feels like a more natural interface.
    Last edited by Lattyware; 06-24-2015 at 03:23 PM.

  6. #6
    Basic Member zedor's Avatar
    Join Date
    Jun 2013
    Posts
    39
    Quote Originally Posted by Lattyware View Post
    Your post appeared to be expecting SetAttribute() to modify the elements, I was giving what I assume is the intended use - what you are talking about is something we'd want alongside the Get/SetAttribute() functionality (which is useful as it stands, as shown above).
    Yep, it did, but I did state what the current behaviour is and added
    If that is not the intended behaviour, then I guess a fix is expected, but if it is, it would be nice to get the ability to change default props/atts like 'text', 'placeholder', etc.
    Your example/explanation stands well on its own but I just thought it strange that you're directing it at me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •