[G4P gui builder tool] OLD: Source code EDIT:generate the handling event functions in other sketch..

I have been trying to find the source code of both the G4P and its tool counterpart in github, with no success. I especially want to modify how the gui tool builder generates the event handlers so as not to put them in the same gui sketch. This is because I usually need to insert code in the handing event functions and I cannot do it in the gui sketch because as you know it gets overwritten every time the tool is opened. If it could generate or copy the code of those functions in a different local sketch, it would be useful.

Regards

EDIT: What was solved was a means to an end. My original intention was to generate the handling event functions in other sketch

Tagged:

Answers

  • edited September 2017 Answer ✓

    I believe that the G4P source is available from SourceForge, as per the download link on its homepage:

    ...although if you have specific ideas / needs, it might be good to chat with @quark about them.

  • edited September 2017

    Well, this is very very embarrassing, but I have remembered that every library you download using the processing library manager gets you a copy of the source code of it. The same applies to the tools.

    Well, thanks jeremy anyway!. (I would delete this post, but the rules say otherwise)

  • Well, my most important need as regards the gui tool builder would be to generate or move the handling event functions to other tab/sketch so as to write my code inside them. Priorly, I used to copy the code to a different sketch, and then delete the code in the gui to avoid duplication.

  • edited September 2017

    Well, this is strange. For some reason now my code doesn't get overwritten. I think I must have skipped reading the changelog of the last updates of the tool. I am not sure if the Code.java class is what allowed this to happen:

    /** * Every event handler method has its own unique id number. This class is used to * store user entered code indexed by the id number.. * * @author Peter Lager * */?

  • Answer ✓

    Well, my most important need as regards the gui tool builder would be to generate or move the handling event functions to other tab/sketch so as to write my code inside them.

    Two things here:

    1) Other Sketch
    Events are sent to the sketch that generates them. This is a Java thing and cannot be changed. Say you had two sketches S1 and S2 also S1 has a command button B1 and S2 has a label L2. If B1 is clicked we want the text in L2 to change.
    So when the button is clicked the OS sends the event to the active application i.e. S2, it cannot send it to S1.

    2) Other Tab
    This is simple enough to do here is the event handler for button B1

    public void btn_B1_click(GButton source, GEvent event) { //_CODE_:b1:468536:
      handleB1event(event);
    } //_CODE_:b1:468536:
    

    notice I have modified the code inside to call a user defined method which can be in any tab (but the gui tab e.g.

    void handleB1event(GEvent event){
      // User defined action here
    }
    

    You could use this method to send data to S1.

    So this solves both problems and modifying the source code to do this is over-the-top.

    For some reason now my code doesn't get overwritten.

    When you use GUI Builder the code in the gui tab is recreated every time you move from the GUI design window to the code window, there are no exceptions.

    When you move from the code window to the design window any code inside the event handlers is saved and the event tab number e.g. _CODE_:b1:468536: is used to tag the code so it can be restored when moving back to the code window i.e. recreating the gui tab code.

    When adding code to the gui tab it MUST be inside an event handler, any other code will be destroyed.

    What version of GUI Builder and Processing are you using?

  • Thanks @quarks for the detailed explanation. It is good to know after all that the code is saved. I guess it has been like that since version 1. I'd swear seeing otherwise in previous versions, but I must be wrong.

    What version of GUI Builder and Processing are you using?

    G4P gui builder tool version = 4.2.1 Processing version= 3.3.6

    Regards

Sign In or Register to comment.