KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4Dv14R5 Custom Toolbar and Auto Hide
PRODUCT: 4D | VERSION: 14 R5 | PLATFORM: Mac & Win
Published On: April 10, 2015

In 4Dv14 R5 a new type of form is introduced, the Toolbar form window. This window is special in that it's position will always be at the top right under the menu and it's horizontal width will span the full size of the screen on Mac OS of the 4D's window on Windows OS. The window also does not contain any borders or window buttons. Other than that the window can be worked with like a normal window, containing multiple pages or subforms to display multiple formats.

While the new toolbar form comes with a method to show and hide the toolbar, and the toolbar can be resized using normal means the methods below provides a technique to have the toolbar have an Auto Hide Function.

For this technique it will require an additional form besides the one(s) to be used a toolbar.
The form:

  • Contains a short invisible button

  • Button set to same size as form with grow setting set for horizontal and none for vertical.

  • The button's On Mouse Enter event is set

  • The form's sizing is set to the invisible button margins set to 0

  • The form's On Load event is set

These settings will allow the form to be a blank strip accross the screen with the entire area covered by the invisible button.

For the Button add the following method:

Case of
 : (Form event=On Mouse Enter)
  ACCEPT
  DIALOG("Toolbar Form Name") //Name of actual form to be used as tool bar
End case


This will change the form and expand it to the desired Toolbar Form when the area is entered with the mouse cursor.

For the Form's method add the following method:

Case of
 : (Form event=On Load)
  RESIZE FORM WINDOW(0;-(Screen height))
End case


When the toolbar's dialog changes back if the form isn't resized there will be a white space, this method will solve that by attempting to reduce the height of the form by the screen's height but will be restricted to the height of the invisible button due to property settings.

Then add the following code to the actual toolbar form's form method:

Case of
 : (Form event=On Mouse Move)
  C_LONGINT($mousex_l;$mousey_l;$mouseButton_l)
  C_LONGINT($left_l;$top_l;$right_l;$bottom_l)
  GET MOUSE($mousex_l;$mousey_l;$mouseButton_l)
  $mousey_l:=$mousey_l+Menu bar height
  GET WINDOW RECT($left_l;$top_l;$right_l;$bottom_l)
  If (($mousex_l>$right_l) | ($mousex_l<$left_l) | ($mousey_l>$bottom_l) | ($mousey_l<$top_l))
   ACCEPT
   DIALOG("HiddenToolBar")
  End if
End case


This method will track the position of the mouse and change the form back to the short invisible button when the Toolbar isn't hovered over with the mouse cursor "hiding" it.



The image is an example of the HiddenToolbar form, the can be modified to taste and the width does not matter, since the button is set to grow and the form will span the horizontal screen or window. The image's height is 8.

When running a toolbar call the HiddenToolbar first, this will open the hidden toolbar as shown below:



When the mouse enters the area it will activate the invisible buttons On Mouse enter method changing to the desired toolbar form and will remain as the correct form until the mosue leaves the toolbar area: