API

The API can be used to call, control, and generate tips through 4D language. Here the mains functions :


Object variable parameter

This component​ is using an object variable as a unique parameter with some "property/value" pairs.

You can found below the various properties optional or mandatory with their types and default values.

Hint : You can add your own extra "property/value” pairs if needed. Keep in mind that the tip_init function will clear all the content of the object variable.


Properties​

MyObjectVariable : is an Object variable. It must be filled with properties and the desired values which will be used to position the target of your tip.

Here the list of the various properties available :


Variables Footprint

The 4D Component "Another Tip” has a very small footprint which is :


Form method setup

If you want to use the visual effects and animations of Another Tip, you need to put the code below in your MethodForm: (MyObjectVariable can be replaced by your own Object Variable)

Case of 

: (Form event=On Load)

GOTO OBJECT(*;"") // Don't focus on a Form Object

C_OBJECT(MyObjectVariable)// Declare an Object variable

tip_init (MyObjectVariable)// init the tip function

: (Form event=On Timer)

tip (MyObjectVariable)

End case


Form Object Picture variable​

You need to add at least one Form Object Picture Variablesvg_pict1* in each form where you want to use the tip function. To help you to add such object on your forms, you can use the Object Library :AnotherTip.4dlibrary/AnotherTip.4IL.

In case you have more than one page on your form, you need to add this form object on each page and set a different object name for each of these Form Object Picture Variable (E.g. svg_pict_page1, svg_pict_page2, etc.) . In this case don’t forget to set the tip-picture-name property with the request name before calling the tip function.

To manage the closeBox you need to add this 2 lines of code to the Method Form Object of the Form Object Picture variable. You can replace MyObjectVariable Object variable by your own variable Object name.

You need to activate the event “on clicked” for this form object.

C_OBJECT(MyObjectVariable)

tip_closeBox_manager (MyObjectVariable)


SubForm Object method setup​

If you want to use subform, it’s mandatory to add the function call “tip_subform_connector” to each method subform object if you want to display a tip linked to a target form object included in your subform. There is no need to activate any specific events for your Subform object.

tip_subform_connector


Creating Tip Styles​

Instead of setting the position, the color, the font, etc. for every tip that you want to display, you can create one or more style and reuse it.

For example you want to set a specific Alert style, you can create a 4D method : "myTipStyle_Alert" like this:

C_OBJECT($1)

$TipObject:=$1

OB SET($TipObject;"tip-width";310)

OB SET($TipObject;"tip-position";"right")

OB SET($TipObject;"font-size";"medium")

OB SET($TipObject;"background-color";"#FF0000")

OB SET($TipObject;"font-color";"#FFFFFF")

OB SET($TipObject;"stroke-size";3)

OB SET($TipObject;"stroke-color";"#FFB6C1")

OB SET($TipObject;"tip-opacity-background";59)

Then you can simply call myTipStyle_Alert just before to call the function tip(TipObject) to display the Tip like this:

myTipStyle_Alert (TipObject)

tip (TipObject)

To help you create tip Style Sheet, you can use the Labs provided with the demo database. This Labs provide a WYSIWYG interface to help you to immediately visualize the result of your various settings.


Best practices

Each time you set a property to your object variable and if it's a process variable, this value will stay associated with the object until you initialize the variable with the tip Command tip_init(MyObjectVariable).

If you want to get ride of initializing the object variable, use a Local Object Variable instead. This way you are sure that your Local Object Variable will be cleared when leaving the current method.

To remove one or more specific properties that you previoulsy setted, you must use the tip command tip_remove_properties(MyObjectVariable).

You can define different Object Process or Interprocess Variable for each tip style that you want to use for displaying your tips. For example you can define a specific Interprocess Object Variable for displaying Alert's tip (background red) : TipObjectAlert with some specifics properties, and another one for displaying Confirmation's tip (background green) : TipObjectConfirmation. etc. This way, you can set all your various tip object variables, in a specific startup method, and simply use the correct tip variable depending of the tip you want to display.

  // Startup tip set style method

myTipStyle_Alert (TipObject_Alert)

myTipStyle_Confirmation (TipObject_Confirmation)

  // tip display

If (Op_done=True)

OB SET(TipObject;"tip-text";"Operation correctly done!")

tip (TipObject_Confirmation)

Else 

OB SET(TipObject;"tip-text";"something went wrong!")

tip (TipObject_Alert)

End if 


  1. E.g. tip_remove_properties(MyObjectVariable;”tip-opacity, tip-shadow, stroke-color”)

  2. This % value is applied globally to all the other opacity properties.


Copyright © 2016 AJAR SA

http://www.ajar.ch