Mouse Events

LANSA Version 13 SP2

Mouse Events


When an application is using DirectX, there are changes to the way in which the list controls (Tree, Grid etc.) appear. Most notably, when the mouse is over an item in the list, the item will be highlighted. In the image below, the first item in the list is the FocusItem. The 5th item has the mouse over it and is therefore the CurrentItem.

The code for this form is available in the Sample Source section of this document.

All LANSA lists use a CurrentItem concept that maps the equivalent field values from the list and into the equivalent variables. CurrentItem effectively represents the item last processed in the list. This might be the last item clicked on, which will also be the FocusItem, or perhaps the last item processed in a Selectlist loop.

Historically, it was common to see processing similar to the above where the Delete button would cause the deletion of the currently selected item with code similar to the following.

Evtroutine Handling(#Delete.Click)

If (#List.CurrentItem *IsNot *null)

Dlt_Entry Number(#List.CurrentItem.Entry) From_List(#List)

Endif

Endroutine

This code effectively assumes the CurrentItem and FocusItem are going to be one and the same, and for most scenarios prior to DirectX that would be the case.

However, in DirectX, MouseOver processing has been added for all lists and takes effect immediately. Even if the related event routines aren’t coded, the runtime is still determining what the CurrentItem is and this can affect the values of variables.

Relying on CurrentItem is not good practice outside of a Selectlist as it can be corrupted. For single selection lists you should always use the FocusItem.