PathFinder

Represents a control where you can navigate through the file system and select a path:

To create a path finder control use the PathFinder::new method with the 3 parameteres: a starting file path, a layout and initialization flags:

let mut control = PathFinder::new("C:\\Program Files", Layout::new("x:1 , y:1 , width:40"), pathfinder::Flags::CaseSensitive)

or the macro pathfinder!

let mut control = pathfinder!(" x: 1, y:1, path: 'C:\\Program Files', w:40"));

A pathfinder supports all common parameters (as they are described in Instantiate via Macros section). Besides them, the following named parameters are also accepted:

Parameter nameTypePositional parameterPurpose
pathStringYes (first postional parameter)The file path used as a starting point when navigating through the file system.
flagsListNoPathFinder initialization flags that control if the path finder is case-sensitive, readonly, etc

A pathfinder supports the following initialization flags:

  • pathfinder::Type::Readonly or Readonly (for macro initialization) - thils will allow you to view or copy the text but not to modify it
  • pathfinder::Type::CaseSensitive or CaseSensitive (for macro initialization) - by default the control is case insensitive, set this if you want it to be case sensitive. Some examples that use these parameters:
let cb = pathfinder!(" x: 1, y:1, path: 'C:\\Program Files', w:40, flags:ReadOnly|CaseSensitive"); let cb = pathfinder!(" x: 1, y:1, path: 'C:\\Program Files', w:40, enabled: false);

Events

To intercept events from a pathfinder, the following trait has to be implemented to the Window that processes the event loop:

pub trait PathFinderEvents { fn on_path_updated(&mut self, handle: Handle<PathFinder>) -> EventProcessStatus {...} }

Methods

Besides the Common methods for all Controls a pathfinder also has the following aditional methods:

MethodPurpose
set_path(...)Set the path for a pathfinder.
path()Returns the current path from a pathfinder.

Key association

The following keys are processed by a PathFinder control if it has focus:

KeyPurpose
Left, RightNavigate through the text from the pathfinder
Shift+{Left,Right}Selects part of the text pathfinder
HomeMove to the begining of the text
Shift+HomeSelects the text from the beging of the text until the current position
EndMoves to the end of the text
Shift + EndSelects the text from current position until the end of the text
DeleteDeletes the current character. If a selection exists, it deletes it first
BackspaceDeletes the previous charactr. If a selection exists, it deletes it first
Ctrl+ASelects the entire text
Ctrl+C or Ctrl+InsertCopy the current selection to clipboard
Ctrl+V or Shift+InsertPaste the text from the clipboard (if any) to current position
Ctrl+X or Shift+DeleteIf a selection is present, it copies it into the clipboard and then delets it (acts like a Cut command)

Aditionally, all printable characters can be used to insert / modify or edit the current text.

Mouse actions

Mouse cursor can be used to select the text. Aditionally, a double click over the control will select all the text.

Example

The following code creates multiple path finders with both unicode and regular text.

use appcui::prelude::*; fn main() -> Result<(), appcui::system::Error> { let mut app = App::new().build()?; let mut w = Window::new("Title", Layout::new("d:c,w:40,h:11"), window::Flags::None); w.add(pathfinder!("path: 'C:\\Program Files',x:1,y:1,w:36,h:1")); w.add(pathfinder!("'C:\\Program Files',x:1,y:3,w:36,h:1, flags: ReadOnly")); w.add(pathfinder!("path:'C:\\Program Files\\Čšambal.exe',x:1,y:5,w:36,h:1,enable: false")); a.add_window(w); a.run(); Ok(()) }