Menu

#45 delete/remove GTextField

1.0
closed
None
enhancement
2021-09-06
2021-09-05
Anonymous
No

When an G4P object, e.g. a text field, is created there is no way stop displaying it and reuse the area in the window for other drawings, e.g. lines, ellipses. This Ticket requests to add a feature to remove/delete an G4P object.
Suggested user interface

import g4p_controls.*;
... // empty window here
GtextField gtf=new GtextField(this,110,130,70,20);
... // window with text field
... // when the text field is not required any more:
gtf.delete(); // requested feature to delete the object
... // empty window here again

I have been looking for this feature but could not find it.
I have posted the question on https://discourse.processing.org/t/how-to-delete-a-g4p-gtextfield/31897 but no one replied, so I assume there is no solution yet.
Regards,
Jos Schouten

Discussion

  • Quarks Processing

    • status: open --> closed
     
  • Quarks Processing

    This feature already exists - see dispose() method. Sameple sketch -
    ```import g4p_controls.*;

    GTextField txf;
    GButton btnRemove;

    public void setup(){
    size(240, 120);
    createGUI();
    }

    public void draw(){
    background(240);
    line(10,10,width-20,height-20);
    }

    public void txf_event_handler(GTextField source, GEvent event) {
    println("txf - GTextField >> GEvent." + event + " @ " + millis());
    }

    public void remove_click(GButton source, GEvent event) {
    println("btnRemove - GButton >> GEvent." + event + " @ " + millis());
    txf.dispose();
    }

    // Create all the GUI controls.
    public void createGUI(){
    G4P.messagesEnabled(false);
    G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
    G4P.setMouseOverEnabled(false);
    surface.setTitle("Sketch Window");
    txf = new GTextField(this, 10, 10, 120, 30, G4P.SCROLLBARS_NONE);
    txf.setOpaque(true);
    txf.addEventHandler(this, "txf_event_handler");
    btnRemove = new GButton(this, 10, 50, 120, 30);
    btnRemove.setText("Remove Textfield");
    btnRemove.addEventHandler(this, "remove_click");
    }

    ```

     

Log in to post a comment.