G4P imagebuttons setZ method protected

edited September 2016 in Library Questions

I'm using G4P ver4.0 library in processing 3.0.
I want to have labels/imagetogglebuttons displayed over top of other imagetogglebuttons.
I have tried creating the buttons in various order, but I cannot seem to control which one appears "on top".
I found the method setZ in the GAbstractControl, but it is a protected function.

How can I set the Z-order/depth of various GUI elements in G4P ?

Thanks,
Dan

@quark

Tagged:

Answers

  • edited September 2016 Answer ✓

    I want to have labels/imagetogglebuttons displayed over top of other imagetogglebuttons.

    My first question would by why?

    The setZ method is protected because z is a calculated field based on the controls position on the display and whether the control is on a floating panel (GPanel). For instance a drop down list (GDropList) is no good if, when activated, is displayed under a button immediately below it.

    Allowing the user to modify the display order directly is likely to cause chaos and this forum full of questions about mouse clicks activating the wrong control etc. So this is not something I am going to enable.

    There are ways round it for instance assume you have 2 image-toggle-buttons (t1 and t2) the same size and in the same position. You can

    // Make t1 active and `on-top` with
    t0.setVisible(false);
    t1.setVisible(true);
    
    // and Make t0 active and `on-top` with
    t0.setVisible(true);
    t1.setVisible(false);
    

    Invisible controls do not respond to mouse clicks so are effectively disabled.

  • edited September 2016

    Hi Quark,

    Thanks for the response. This is what I'm trying to do: imagetogglebuttons2
    I'm wanting to use either Labels and/or ImageToggleButtons as "Overlay Graphics" over my Tabs(ImageToggleButtons). If I incorporate the indicators as part of the image for the tabs, it will add an unreasonable amount of states.
    I got this one to display 'over' the Tab by placing the co-ords slightly outside the Tab's co-ords.

    I also tried using plain 2d drawing (eg line(x,y,xx,yy);) in processing to draw the indicators in code, but these also appear 'under' the gui elements.

    Perhaps you can suggest a better practice to what I want to do?

    Thanks again,
    Dan

  • I solved my problem by making the larger Tab buttons have transparent 'holes' in them for the Overlay buttons:
    tab

    Thanks, Dan

Sign In or Register to comment.