114 views
in GUI Development by

Hi,

 

Note : Red Highlight indicates the current focus

Query:

how to find whether the current focused element is the last visible element in the menu display?

In the above flow diagram, Initially the Cursor will be in Item1 . Then on each down it will move to Item2,Item3,Item4 ... Item7 again on down it will move to Item1.

Note : The number of visible elements in the display at a time can be 4 Items,

  • Case 1 :  Initially Item1 to Item4 will be in the display. When Down Key is pressed from Item 3, the Cursor will be in last visible element in the display i.e. Item4.
  • Case 2 : When Down Key Press is done from Item 4, then Item5 will be visible. Now Item2 to Item5 will be in the Visible window, i.e. these elements will be visible to the user. Here the Cursor will be in last visible element in the display i.e. Item5.
  • Case 3 : When Down Key Press is done from Item 5, then Item6 will be visible. Now Item3 to Item6 will be in the Visible window, i.e. these elements will be visible to the user . Here the Cursor will be in last visible element in the display i.e. Item6.

Here how to find whether the current focused element is the last visible element in the menu display (i.e. Item 4, Item5 and Item6 respectively for Case 1, Case2 and Case3 as mentioned above will be the last visible item in the display and also it will be in Focus).

Any API's to get the same? 

 

Note : We are using Outline.EnsureVisible() to bring the Item to Focus

 

Best Regards,

Preethi S

Robert Bosch - India

 

 

 

1 Answer

0 votes
by

Hello Preethi,

compare in this case the Bounds of the Item with the Bounds of the surrounding area. Assuming, the items are managed within an Outline, calculate an intersection between the Bounds of the Item and the Bounds of the Outline. If the intersection is empty, the item lies completely outside the area. If the intersection is equal to the Bounds of the item, the item lies completely within the area. Finally if none of the cases is true, the item lies partially inside/outside the area. 

To calculate the intersection use the & operator. to compare the rectangles after the intersection use the == operator. To test whether a rectangle is empty you can also use the instant property isempty. For example, to test whether ItemX is inside or outside the area of Outline:

if (( ItemX.Bounds & Outline.Bounds ) == ItemX.Bounds )
  trace "the item is completely inside Outline";

if (( ItemX.Bounds & Outline.Bounds ).isempty )
  trace "the item is completely outside Outline";

 

EDIT: An additional hint: with the EnsureVisible() method you already achieve the effect of automatically scrolling the Outline contents. Just invoke EnsureVisible( FocusedItem ) just after changing the focus. The method takes care of scrolling the menu or, if it is not necessary, it returns without doing anything.

Does it help you further?

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...