Block UI Styler > Block Catalog > Basic > String
Keystroke callback for the String block
For every String block added to a dialog box, NX provides a Keystroke callback.
Syntax
Public Function KeystrokeCallback(ByVal string_block As NXOpen.BlockStyler.StringBlock, ByVal uncommitted_value As String) As Integer
End Function
Input parameters
- string_block — Refers to the string block in which text is being typed.
- uncommitted_value — Contains the uncommitted text being typed in the string block.
Usage
By default, this callback is commented out. To use it, uncomment the callback and write code in the callback function to perform the required processing. NX provides this callback in all supported programming languages.
Use this callback to process each input keystroke of the dialog box user — for instance, to filter or sort list values per the keystrokes typed in the String block.
Example
When you build a dialog box that contains a List block and a String block with the following keystroke callback, designers can filter the strings populated in the List block per the text entered in the String block:
'------------------------------------------------------------------------------
'StringBlock specific callbacks
'------------------------------------------------------------------------------
Public Function KeystrokeCallback(ByVal string_block As NXOpen.BlockStyler.StringBlock, ByVal uncommitted_value As String) As Integer
'Filter/sort string list based on uncommitted value
Dim filteredStrings() As String = getSortedFeatureIDs(uncommitted_value)
'Set filtered list to list box in dialog.
list_box0.SetListItems(filteredStrings)
End Function
This demonstrates the classic "type-ahead filter" pattern: as the user types into the String block, the KeystrokeCallback fires on every keystroke with the in-progress (uncommitted) text, and the callback body re-filters/re-sorts a companion List Box's items using SetListItems.
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.blockstyler/xid1474058 · retrieved 2026-07-07