KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Displaying a marker for an item in a scrollable area
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: February 22, 2002

Version: 6.5.x and 6.7.x

The following technique gives the user an ability to display a marker for the selected item in scrollable area.


In the example, two scrollable areas are created: sArea1 and sArea2.


Step 1:


The first thing that you need to do is to assign a value for each element of the array. In this example, suppose the elements of both objects are created procedurally when the On Load event is executed.

If(Form event=On Load)

ARRAY TEXT(sArea1;5)


sArea1{1}:="Element 1"

sArea1{2}:="Element 2"

sArea1{3}:="Element 3"

sArea1{4}:="Element 4"

sArea1{5}:="Element 5"

ARRAY TEXT(sArea2;5)


sArea2{1}:=""

sArea2{2}:=""

sArea2{3}:=""

sArea2{4}:=""

sArea2{5}:=""


End if


Note: sArea2 also has a maximum of 5 elements each of which each element is an empty string (""). This object will be used to display the marker when the user clicks on an item.


Important: Both scrollable areas must have the same number of elements.


Step 2:


Place the following code in the object method of both scrollable areas and make sure the On Clicked form event is selected for both of them.

If (Form event=On Clicked )

  SetElementChecker (->sArea2;Self->)


End if


Step 3:



Create the following project method.


` Project Method: SetElementChecker

` $1 - Pointer to the array to turn on the marker


` $2 - Selected position

C_POINTER
($1)

C_LONGINT($2;$vlPlatform;$vlSystem;$vlMachine)

If ($1->{$2}="")

  PLATFORM PROPERTIES($vlPlatform;$vlSystem;$vlMachine)

  If ($vlPlatform=3)

   $1->{$2}:=Char(161)


  Else


   $1->{$2}:=Char(195)

  End if

Else

   $1->{$2}:=""

End if


Step 4:


Group both scrollable areas together. To do this, you need to highlight both object and select "Group" from the Object menu or use the Group tool from the Tools palette.


Here are the results when the user clicks on Element 1, Element 3 and Element 4.



Windows



Mac OS