FMX.SearchContext Sample

From RAD Studio Code Examples

This sample demonstrates how to create and use a search context and how to use FireMonkey image effects.

Location

You can find the SearchContext sample project at:

  • Start | Programs | Embarcadero RAD Studio Florence | Samples and navigate to:
    • Object Pascal\Multi-Device Samples\User Interface\SearchContext
    • CPP\Multi-Device Samples\User Interface\SearchContext
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search for the sample by name in the repository corresponding to your RAD Studio version.

Description

By modifying a TClearingEdit, the sample highlights a field and its associated icons using opacity and glow effects. It also provides a menu with options for loading and managing data, and uploading new images using LiveBindings.

Select Options > Manage Data to configure the search options. You can also double-click an icon image to add more icons.

How to Use the Sample

  1. To run the example, open its project file:
    • Delphi: SearchContext.dproj
    • C++: SearchContext_Cpp.cbproj
  2. Press F9 or choose Run > Run.
  3. Start typing a search term that matches the beginning of one of the "INTERNET" or "SYSTEM" items to see the matching item highlighted.
Note: To deploy this sample application, you must first:
  1. Add the iconData.cds file to the Deployment Manager for each target platform.
  2. Add the MIDAS library to the Deployment Manager for each target platform.

Files

File Class
unitSearchMenuHelperCpp The TSearchItem, TSearchBand, and TSearchBandManager classes.
formMain
  • Delphi: The TfrmManageData class.
  • C++: The TfrmData class.
dataData The TdtmdlData class.
formMain The TfrmMain class.

SearchContext (Delphi)
SearchContext_Cpp (C++)

The sample project files.

Classes

  • TSearchItem is a TLayout descendant that represents an item and its associated information. It contains:
  • TfrmData is a secondary form accessible through the Options > Manage Data command. It descends from TForm and contains:
  • TfrmMain is the main form that provides the user interface. It descends from TForm and contains:

Implementation

When you run the application, the main window of the sample is displayed. You can perform the following actions:

  • Select Options > Load Data to load the data. The sample also loads the data automatically when the main form is created.
  • Select Options > Load Images to open a file dialog where you can select and load a new cdsIconData dataset after closing the previously loaded dataset.
  • Select Options > Manage Data to open a TForm where you can use TBindNavigator to add, delete, and navigate through items.
  • Search for a word and observe how the TGlowEffect and opacity change around the icons whose labels or associated search terms match the search text. The icons can display no glow, a partial glow (when only part of the word matches), or a full glow.
  • Double-click an icon to display its corresponding list of search terms.

Uses