(Spout) onClick event?

Discussion in 'Plugin Development' started by Uhehesh, Oct 8, 2011.

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

    Uhehesh

    Hello.
    I am adding Spout integration to my plugin. I've almost finished it, but I still have one problem.

    There is
    void onButtonClick(ButtonClickEvent event)
    function.​
    As far as I know, all the events first go trough event listeners and then trough general ScreenListener. Right?​
    I have some events in ScreenListener but I also want to use onButtonClick(...) because it is easier to use.​
    So what is ButtonClickEvent?​
    Thanks.​
     
  2. Offline

    Afforess

    It's merely a utility. Events still go through the event listeners, but they also go to the button itself. By default, it's empty, but you can override the function and do your stuff for the event in there, instead of having to identify the button in a listener.
     
    Uhehesh likes this.
  3. Offline

    Uhehesh

    Thanks for your answer.

    But how?
    I have container with one page that contains list with labels and buttons.
    I need to update it when "Previous" or "Next" buttons are clicked. But I am really confused because I am trying to find working solution since morning.

    Something about Spout (open)

    Spout is awesome! Thank you.

    P.S. I suggest Spout widgets must have setTag(Object...) and getTag(Object...) to bind information? Some developers like me are accustomed to use this way.
     
  4. Offline

    Afforess

    It's pretty easy. Say you want your previous button to be a self-contained button:
    Code:
    public class MyPreviousButton extends GenericButton {
        public MyPreviousButton() {
            super();
            setText("Previous");
        }
        public void onButtonClick(ButtonClickEvent event) {
            //do click stuff
        }
    }
    
     
    Uhehesh likes this.
  5. Offline

    Uhehesh

    OK, it helped me. So I just added that class to my container.
    But I still have one problem. I need to delete and recreate existing container on button click. I pass Container to my button constructor. I need to replace it with my new container generated by helper function (OR delete all the widgets there and replate them with new ones). How can I do this? I can't find "removeWidget()" function etc.
    Or maybe I am doing it wrong?

    Thank you again and excuse me that I disturb you.

    *problem is solved*

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
Thread Status:
Not open for further replies.

Share This Page