Difference between revisions of "LazControls"

From Free Pascal wiki
Jump to navigationJump to search
Line 1: Line 1:
LazControls is a set of controls that are often used in Lazarus.
+
LazControls is a set of controls that are often used in Lazarus IDE itself, but they can be used elsewhere, too.
  
 
= FilterEdit controls =
 
= FilterEdit controls =
  
 
Controls inherited from TCustomControlFilterEdit provide a filtering edit box connected to a container control.
 
Controls inherited from TCustomControlFilterEdit provide a filtering edit box connected to a container control.
Currently there filters for TListBox and TTreeView implemented.
+
Currently there are filters for TListBox and TTreeView implemented.
 
When the container control is connected to the filter control, the filtering happens automatically as a user enters text.
 
When the container control is connected to the filter control, the filtering happens automatically as a user enters text.
 +
When the filter in empty and does not have focus, it shows a grey "(filter)" text.
 +
 
There are some common properties that control the behavior:
 
There are some common properties that control the behavior:
  
* property OnFilterItem
+
* property OnFilterItem -- a user can provide an event handler to give extra conditions for filtering, in addition to the default behavior. This feature has for example enabled filtering the Options windows in Lazarus IDE, based on captions of all controls on the options pages.
* property OnCheckItem
+
 
* property UseFormActivate
+
* property OnCheckItem -- This has effect when items in the filtered container can be checked. ToDo: improve...
 +
 
 +
* property UseFormActivate -- Sometimes the control's OnEnter and OnExit handlers are not called when focus is moved directly to/from another window.
 +
Then the gray "(filter)" can remain visible even when the control gains focus.
 +
When UseFormActivate is True, it finds the parent form and registers handlers for its OnActivate and OnDeactivate events. They properly keep track when the control has focus.
 +
This setting is False by default to make sure no existing event handler is overwritten. (An improvent could be to save an existing handler before registering a new one.)
  
 
== TListFilterEdit ==
 
== TListFilterEdit ==
  
This is a control that can easily filter a ListBox.
+
This control can filter a ListBox. It has a property
 +
* FilteredListBox
 +
 
  
 
Once property TListFilterEdit.FilteredListBox is assigned then TListFilterEdit makes copy of ListBox.Items and works with it. If you add ListBox.Items.Add later, then these data does not appear in TListFilterEdit.
 
Once property TListFilterEdit.FilteredListBox is assigned then TListFilterEdit makes copy of ListBox.Items and works with it. If you add ListBox.Items.Add later, then these data does not appear in TListFilterEdit.

Revision as of 21:29, 22 May 2012

LazControls is a set of controls that are often used in Lazarus IDE itself, but they can be used elsewhere, too.

FilterEdit controls

Controls inherited from TCustomControlFilterEdit provide a filtering edit box connected to a container control. Currently there are filters for TListBox and TTreeView implemented. When the container control is connected to the filter control, the filtering happens automatically as a user enters text. When the filter in empty and does not have focus, it shows a grey "(filter)" text.

There are some common properties that control the behavior:

  • property OnFilterItem -- a user can provide an event handler to give extra conditions for filtering, in addition to the default behavior. This feature has for example enabled filtering the Options windows in Lazarus IDE, based on captions of all controls on the options pages.
  • property OnCheckItem -- This has effect when items in the filtered container can be checked. ToDo: improve...
  • property UseFormActivate -- Sometimes the control's OnEnter and OnExit handlers are not called when focus is moved directly to/from another window.

Then the gray "(filter)" can remain visible even when the control gains focus. When UseFormActivate is True, it finds the parent form and registers handlers for its OnActivate and OnDeactivate events. They properly keep track when the control has focus. This setting is False by default to make sure no existing event handler is overwritten. (An improvent could be to save an existing handler before registering a new one.)

TListFilterEdit

This control can filter a ListBox. It has a property

  • FilteredListBox


Once property TListFilterEdit.FilteredListBox is assigned then TListFilterEdit makes copy of ListBox.Items and works with it. If you add ListBox.Items.Add later, then these data does not appear in TListFilterEdit.

You should do always:

TListFilterEdit.FilteredListBox:=nil;
//Add data to ListBox
TListFilterEdit.FilteredListBox:=ListBox;