Change GenericLabel from another class

Discussion in 'Plugin Development' started by grichecth, Nov 21, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    grichecth

    Hi All,

    I have a popup defined in my main class, under a onCommand. I have a screenlistener class to detect button pushes. When I click a button I want a label in my main class to change text. How would I interact with the label from another class?

    Been trying things all night but i'm still new at this so i'm getting no where with it.

    Hope someone can help..

    Anyone? This cannot be that hard.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
  2. Offline

    polaris120990

    @grichecth what exactly do you mean by a label?
     
  3. Offline

    desht

    It's a Spout question - to the OP, it's a good idea to put [SPOUT] in the thread title for any Spout-related questions.

    Also to the OP: I would recommend subclassing GenericPopup with your own class. You can create the GUI structure for your popup in the constructor for your new class, and use the inherited methods to show/hide your new popup object(s). You can add the necessary fields & methods to your new class, e.g. the label you want to access from other classes, and a method to set the text of your label.

    Then it's just a matter of getting a reference to your popup object in the screen listener handler. You could make it a field in your main plugin class, with an accessor method for your screen listener to grab it, for example.
     
  4. Offline

    Afforess

    You want to save the label in a variable in your plugin class, then add an accessor to it. (e.g getMyFancyLabel()).

    Then in your commandExecutor, you use myPlugin.getMyFancyLabel.doStuff().
     
  5. Offline

    grichecth

    Beauty! Works great. Thanks =)
     
Thread Status:
Not open for further replies.

Share This Page