Results 1 to 5 of 5

Thread: Add a way to get the element an event was fired for

  1. #1
    Basic Member
    Join Date
    Jan 2013
    Posts
    1,547

    Angry Add a way to get the element an event was fired for

    If you set elem.SetPanelEvent("something",something) you can't get the element itself, because JS doesn't allow to hardcode event parameters, unlike listeners added directly in a layout file. So any dynamically created elements can't be referred to from their own event handlers, nor any their data of interest. This currently leaves any attempts to create fully dynamic UI impossible, as it can't properly react to any event if there are more than 1 elements with the same event handler. I'm stuck with this issue currently and can't progress any further.

  2. #2
    Basic Member
    Join Date
    Aug 2015
    Posts
    4
    You can pass in a function built by a function like so

    Code:
          root_pane.SetPanelEvent('onactivate', function() {
            return ItemPanelOnActivate(root_pane);
          });
          root_pane.SetPanelEvent('onmouseover', function() {
            return ItemPanelMouseOver(root_pane);
          });
          root_pane.SetPanelEvent('onmouseout', function() {
            return ItemPanelMouseExit(root_pane);
          });
    This currently leaves any attempts to create fully dynamic UI impossible
    You fucking what
    Last edited by gigimoi; 10-30-2015 at 12:29 PM.

  3. #3
    Basic Member
    Join Date
    Jan 2013
    Posts
    1,547
    I'm talking about creating a set of identical elements in row. If I just blindly do it like you variable capture won't let me work with each element. Instead it will make all elements handlers get the last created element as a parameter. Fucking what??? Yes, I tried to create a purely dynamic settings UI by using JS objects as a prototype to construct from, but this has bitten me in the knees.

  4. #4
    Basic Member
    Join Date
    Nov 2011
    Posts
    236
    Maybe you can follow something like this example to get around last element always being the same?
    http://stackoverflow.com/questions/7...ctical-example

    In my mod, for dynamically created checkboxes, I have their layout and js event handler defined in separate files (.xml, .js), then in the event handler, I use

    checkboxPanel = $.GetContextPanel()

    to get the checkbox that was clicked. My checkboxes simply just send their selected/deselected state to the server, though.
    Training Map for Last Hitting Under a Tower:
    http://steamcommunity.com/sharedfile.../?id=531587903

  5. #5

Posting Permissions

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