# G4P GPanel behaviour

**URL:** <https://discourse.processing.org/t/g4p-gpanel-behaviour/42134>\
**Category:** Libraries\
**Created:** [June 3, 2023, 11:24pm UTC](https://discourse.processing.org/t/g4p-gpanel-behaviour/42134 "2023-06-03T23:24:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harrih](https://avatars.discourse-cdn.com/v4/letter/h/ed655f/32.png) [@harrih](https://discourse.processing.org/u/harrih)\
**Post date:** [June 3, 2023, 11:24pm UTC](https://discourse.processing.org/t/g4p-gpanel-behaviour/42134/1 "2023-06-03T23:24:46Z")

</div>

Hello,

Regarding behaviour of GPanel  
I am trying to make the entire surface of a GPanel responsive to an  
.isOver type event  
It appears that normal behaviour is for only the tab area to respond to mouseEvents not the body.  
I have found that increasing the tab size to cover the entire panel works  
but it is clunky to do, as I have to play with font sizes and letter choices to get the areas to match.  
Catch with this is that it that it does make the Panel accidentally draggable.  
when doing things inside the Panel

Is there a more elegant way or possibly a completely different approach.

The purpose of this is to be able to summon a normally hidden helper panel  
whenever required and then dismiss the Panel when done by mousePressing **outside** the GPanel  
anywhere else on the screen.

the test I am using is

> void mousePressed(){  
> if (panel1.isOver()==false){panel1.setVisible(false);  
> }

thanks  
Harry

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [June 4, 2023, 6:59am UTC](https://discourse.processing.org/t/g4p-gpanel-behaviour/42134/2 "2023-06-04T06:59:32Z")

</div>

> [@harrih](#):
>
> It appears that normal behaviour is for only the tab area to respond to mouseEvents not the body.

That’s correct. If otherwise there would be a conflict between the panel and any controls placed on the panel.

> [@harrih](#):
>
> dismiss the Panel when done by mousePressing **outside** the GPanel

There is no easy way to do this but you could hide the panel when it is collapsed like this

```auto
// Panel event handler
public void panel1_Click1(GPanel source, GEvent event) { //_CODE_:panel1:248744:
  println("panel1 - GPanel >> GEvent." + event + " @ " + millis());
  if (event == GEvent.COLLAPSED)
    panel1.setVisible(false);
} //_CODE_:panel1:248744:

```

---

<div class="post-metadata">

**Author:** ![harrih](https://avatars.discourse-cdn.com/v4/letter/h/ed655f/32.png) [@harrih](https://discourse.processing.org/u/harrih)\
**Post date:** [June 5, 2023, 11:28am UTC](https://discourse.processing.org/t/g4p-gpanel-behaviour/42134/3 "2023-06-05T11:28:00Z")

</div>

Thanks for that it works but I was trying to avoid cursor placement precision  
and an unnecessary extra click.  
In practice Im finding that the very large tab technique does work as the odd  
frame drag occurs but doesn’t really cause much bother  
FWIW this helper app is a rudimentary calculator much like the basic osx calc  
to assist entering values into value input boxes in the main app.

As I think more on it maybe I should use a window as the container instead.  
In which case can I transfer the focus to the main window by clicking a button on the auxiliary window ( I use clicking on the result display as the method to transfer that value back to the main panel)

Thanks  
Harry
