cdk_traverse(3)
π cdk_traverse β the keyboard-traversal era of your CDK era π
okay bestie, settle in, because this is the page from the cdk_traverse(3) manual β a Library calls page, no cap β and it's all about moving focus around a screen full of widgets like the main character you are. π
β¨ NAME β¨
cdk_traverse β Cdk functions for keyboard traversal πΉπ«
π¦ SYNOPSIS π¦
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
CDKOBJS *getCDKFocusCurrent (CDKSCREEN *screen);
CDKOBJS *setCDKFocusCurrent (CDKSCREEN *screen, CDKOBJS *obj);
CDKOBJS *setCDKFocusFirst (CDKSCREEN *screen);
CDKOBJS *setCDKFocusLast (CDKSCREEN *screen);
CDKOBJS *setCDKFocusNext (CDKSCREEN *screen);
CDKOBJS *setCDKFocusPrevious (CDKSCREEN *screen);
int traverseCDKScreen (CDKSCREEN *screen);
void exitOKCDKScreen (CDKSCREEN *screen);
void exitCancelCDKScreen (CDKSCREEN *screen);
void resetCDKScreen (CDKSCREEN *screen);
void exitOKCDKScreenOf(CDKOBJS *obj);
void exitCancelCDKScreenOf (CDKOBJS *obj);
void resetCDKScreenOf (CDKOBJS *obj);
void traverseCDKOnce (
CDKSCREEN *screen,
CDKOBJS *curobj,
int keyCode,
boolean functionKey,
CHECK_KEYCODE funcMenuKey);
πΈ DESCRIPTION πΈ
so the functions up there π are the whole friend group that handles traversal of a screen that's been populated with various widgets. once you've created the screen and filled it with widgets, one single call to traverseCDKScreen() is all it takes for the user to move between widgets and enter data (or otherwise manipulate widgets). literally one call, that's the vibe. β¨
other functions in the lineup are there to be used as callbacks by the widgets on the screen. and then, finally, there are several functions that let the caller manipulate the state of the traversal β i.e., the object which has focus. that's the whole point, bestie, focus is the currency here. π
for widgets to be usable on a screen that's going to be handled by traverseCDKScreen(), it must have the following methods available:
injectCharObj
inputWindowObj
focusObj
unfocusObj
saveDataObj
refreshDataObj
plus, the following object properties have to be properly handled:
acceptsFocus
hasFocus
inputWindow
dataPtr
dataType
at the time of this writing, not all widgets have been modified to work with the screen-traversal facility. π
π AVAILABLE FUNCTIONS π
π int traverseCDKScreen (CDKSCREEN *screen);
this is THE main screen traversal engine, the icon, the moment. here's what it does:
- calls the
refreshDatamethod on each of the widgets, telling them to update their appearance to match the data which are referenced by their respective data pointers. - calls the
focusObjectmethod on the first widget. - repeats the following until one of the exit functions listed above has been called:
- read a keystroke from the keyboard.
- if the keystroke is ESCAPE and a menu widget is present, activate the menu and traverse it until the user selects an entry or hits TAB.
- if the keystroke is TAB/BACKTAB then call the
unfocusObjectmethod on the current widget, and move focus to the next/previous widget (not counting menu widgets). call thefocusObjectmethod on the newly current widget. - if the keystroke is the EXIT-SAVE keystroke, then call the
saveDatamethod on each widget and return1. - if the keystroke is the EXIT-CANCEL keystroke, return
0without saving changes made by the user. - if the keystroke is the RESET-DATA keystroke, then call the
refreshDatamethod on each of the widgets to reset their appearance to match the data values that were present upon entry. - otherwise, pass the keystroke to the current widget.
π CDKOBJS *getCDKFocusCurrent (CDKSCREEN *screen);
returns a pointer to the object which currently has focus in the given screen. the moment's current holder, fr fr.
π«Ά CDKOBJS *setCDKFocusCurrent (CDKSCREEN *screen, CDKOBJS *obj);
sets the focus to the given object, if the screen contains that object. if the screen does not contain the object, returns null. otherwise, returns the object. it's giving "you can sit with us, but only if you're on the list". π
β CDKOBJS *setCDKFocusFirst (CDKSCREEN *screen);
sets focus on the first object in the given screen.
π¦ CDKOBJS *setCDKFocusLast (CDKSCREEN *screen);
sets focus on the last object in the given screen.
β¨ CDKOBJS *setCDKFocusNext (CDKSCREEN *screen);
sets focus on the next object in the given screen.
π CDKOBJS *setCDKFocusPrevious (CDKSCREEN *screen);
sets focus on the previous object in the given screen.
π₯ exitOKCDKScreen
causes the traversal engine to exit after calling the saveData method for each of the widgets. saving on the way out, obsessed.
πΈ exitOKCDKScreenOf
calls exitOKCDKScreen() on the screen associated with widget obj. this function was designed to be used as a callback routine for a button widget used as an OK button on a data-entry screen. iykyk.
π exitCancelCDKScreen
causes the traversal engine to exit without saving user modified data. bye, changes, you never happened. π
π§ exitCancelCDKScreenOf
calls exitCancelCDKScreen() on the screen associated with widget obj. this function was designed to be used as a callback routine for a button widget used as a Cancel button on a data-entry screen.
π resetCDKScreen
causes the traversal engine to call the refreshData method for each widget. this will cause any unsaved changes to be discarded and the widget states will be restored to their initial values. full factory reset energy, periodt.
π resetCDKScreenOf
calls resetCDKScreen() on the screen associated with widget obj. this function was designed to be used as a callback routine for a button widget used as a Reset button on a data-entry screen.
π traverseCDKOnce
this is a utility function β one of the pieces from which you can construct a customized version of traverseCDKScreen. build-your-own-icon kit, basically. π
π BUGS π
not all widgets have had the extra methods added so that they work with the screen traversal engine. some of them simply did not get the memo. π
π«Ά AUTHORS π«Ά
Grant Edwards, Aspen Research Corporation Thomas E. Dickey and contributors.
π SEE ALSO π
cdk(3), cdk_binding(3), cdk_display(3), cdk_screen(3)
and that's the whole page, bestie β from the cdk_traverse(3) manual, this little bundle of joy came stamped with 2024-03-28 as its date. mwah, take care of your focus, it's precious. ππβ¨
π¦ where this page comes from
- debian trixie: libcdk5-dev 5.0.20250116-1 Β· BSD-4-Clause
- fedora 43: cdk 5.0.20240619-4.fc43 Β· LicenseRef-Callaway-BSD-with-advertising
- fedora 43: cdk 5.0.20240619-4.fc43 Β· LicenseRef-Callaway-BSD-with-advertising
- fedora 43: cdk 5.0.20251014-1.fc43 Β· X11-distribute-modifications-variant
- fedora 43: cdk 5.0.20251014-1.fc43 Β· X11-distribute-modifications-variant
- fedora 44: cdk 5.0.20251014-3.fc44 Β· X11-distribute-modifications-variant
- fedora 44: cdk 5.0.20251014-3.fc44 Β· X11-distribute-modifications-variant
- nixos 26.05: cdk 5.0-20260119
- nixpkgs unstable: cdk 5.0-20260119
- ubuntu questing: libcdk5-dev 5.0.20250116-1
- ubuntu resolute: libcdk5-dev 5.0.20251014-1 Β· BSD-4-Clause
- ubuntu stonking: libcdk5-dev 5.0.20260119-1 Β· BSD-4-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms