Documentation | StorageKit | FilePanel
NAME
FilePanel
VERSION
0.01
SYNOPSIS
Perl
use HaikuR1::FilePanel qw(:all);
my $panel = HaikuR1::FilePanel->new(
mode => $mode,
target => $target,
directory => $directory,
flavors => $flavors,
allowMultipleSelection => $allowMultipleSelection,
message => $message,
filter => $filter,
modal => $modal,
hideWhenDone => $hideWhenDone,
);
$panel->Show();
Python
from HaikuR1.StorageKit import FilePanel, B_CANCEL_BUTTON, B_DEFAULT_BUTTON, B_OPEN_PANEL, B_SAVE_PANEL
panel = FilePanel(
mode = mode,
target = target,
directory = directory,
flavors = flavors,
allowMultipleSelection = allowMultipleSelection,
message = message,
filter = filter,
modal = modal,
hideWhenDone = hideWhenDone,
)
panel.Show()
DESCRIPTION
Exposes the BFilePanel object.
For more information on FilePanel, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates a FilePanel.
Perl
HaikuR1::FilePanel->new(
mode => $mode,
target => $target,
directory => $directory,
flavors => $flavors,
allowMultipleSelection => $allowMultipleSelection,
message => $message,
filter => $filter,
modal => $modal,
hideWhenDone => $hideWhenDone,
);
Python
FilePanel(
mode = mode,
target = target,
directory = directory,
flavors = flavors,
allowMultipleSelection = allowMultipleSelection,
message = message,
filter = filter,
modal = modal,
hideWhenDone = hideWhenDone,
)
modeAn integer, one of the mode constants; defaults to
B_OPEN_PANEL.targetA Messenger rperesenting the target to which messages wiill be sent when a file is selected; defaults to
be_app_messenger.directoryA string, the directory to start in; defaults to current working directory.
flavorsAn integer combination of node flavor constants; defaults to
B_FILE_NODE. (Only applies toB_OPEN_PANEL.) See SetNodeFlavors for details.allowMultipleSelectionA boolean, indicates whether to allow multiple files to be chosen; defaults to true. (You can leave this true for
B_SAVE_PANEL, but it doesn't make much sense; you probably want false.)messageA Message template to be sent to your target when the user confirms (or cancels). See (SetMessage)(#SetMessage) for defaults.
filterA RefFilter.
modalA boolean, indicates whether the panel is modal; defaults to false. (A modal panel cannot be closed from the tab; instead, a button must be selected.)
hideWhenDoneA boolean, indicates whether the panel will be automatically hidden when the user confirms or cancels.
A note on node flavors:
B_FILE_NODE- if not included in the node flavors, the open button will be disabled when a file (or symlink to a file) is chosen.B_DIRECTORY_NODE- if included, the open button will send the directory to the target; if not included, the open button will open the directory in the panel.B_SYMLINK_NODE- if included, then directory symlinks will be sent to the target regardless of whetherB_DIRECTORY_NODEis included. If not included, then directory symlinks will be treated like directories. Does not affect handling of file symlinks.
Please note that symlinks are not resolved; the value passed in the message will be the name of the symlink, not the name of the underlying file.
Labels
SetSaveText
SetButtonLabel
Sets the default file name or the button labels.
Perl
$filepanel->SetSaveText($text); $filepanel->SetButtonLabel($button, $label);
Python
filepanel.SetSaveText(text) filepanel.SetButtonLabel(button, label)
text,labelA string, the new name or label.
buttonAn integer, one of the button constants.
Messenger
Returns the Messenger that will be used to send messages in response to events.
Perl
$filepanel->Messenger();
Python
filepanel.Messenger()
PanelMode
Returns the panel mode.
Perl
$filepanel->PanelMode();
Python
filepanel.PanelMode()
RefFilter
Returns the RefFilter associated with the FilePanel.
Perl
$filepanel->RefFilter();
Python
filepanel.RefFilter()
Refresh
Runs the entries in the panel's current directory through the RefFilter again.
Note that you do not need to call this method to update the panel when the contents of the directory change; that will happen automatically.
Perl
$filepanel->Refresh();
Python
filepanel.Refresh()
SelectedRefs
GetNextSelectedRef
Rewind
GetNextSelectedRef and Rewind allow you to iterate through the selected
entries.
SelectedRefs is not part of the Haiku API. It is a convenience method
implemented in the glue code, allowing you to get all the selected items at
once, wrapped up in a native list.
Perl
$filepanel->SelectedRefs(); $filepanel->GetNextSelectedRef(); $filepanel->Rewind();
Python
filepanel.SelectedRefs() filepanel.GetNextSelectedRef() filepanel.Rewind()
Settings
SetTarget
SetMessage
SetRefFilter
SetNodeFlavors
SetPanelDirectory
GetPanelDirectory
SetHideWhenDone
HidesWhenDone
These methods change the settings used to create the FilePanel.
Notes:
There are getter methods only for panel directory and hide-when-done.
There are no setter methods for mode allow-multiple-selection, and modal; these cannot be changed after object creation.
Perl
$filepanel->PanelMode(); $filepanel->SetTarget($target); $filepanel->SetMessage($message); $filepanel->SetRefFilter($filter); $filepanel->SetNodeFlavors($flavors); $filepanel->SetPanelDirectory($directory); $filepanel->GetPanelDirectory(); $filepanel->SetHideWhenDone($hideWhenDone); $filepanel->HidesWhenDone();
Python
filepanel.PanelMode() filepanel.SetTarget(target) filepanel.SetMessage(message) filepanel.SetRefFilter(filter) filepanel.SetNodeFlavors(flavors) filepanel.SetPanelDirectory(directory) filepanel.GetPanelDirectory() filepanel.SetHideWhenDone(hideWhenDone) filepanel.HidesWhenDone()
targetA Messenger rperesenting the target to which messages wiill be sent when a file is selected; defaults to
be_app_messenger.directoryA string, the directory to start in; defaults to current working directory.
flavorsAn integer combination of node flavor constants; defaults to
B_FILE_NODE. (Only applies toB_OPEN_PANEL.) See SetNodeFlavors for details.messageA Message template to be sent to your target when the user confirms (or cancels). See (SetMessage)(#SetMessage) for defaults.
filterA RefFilter.
hideWhenDoneA boolean, indicates whether the panel will be automatically hidden when the user confirms or cancels.
Show
Hide
IsShowing
These methods so what you expect.
Perl
$filepanel->Show(); $filepanel->Hide(); $filepanel->IsShowing();
Python
filepanel.Show() filepanel.Hide() filepanel.IsShowing()
Window
Returns the Window created by the FilePanel object.
Perl
$filepanel->Window();
Python
filepanel.Window()
EVENTS
SelectionChanged
Called when the selection changes. (Use SelectedRefs to get the new selection.)
Perl
$filepanel->SelectionChanged();
Python
filepanel.SelectionChanged()
SendMessage
Called when the Save or Open button is clicked. The default versions uses the [Messenger] to send the message, so you either need to do that yourself or call the default version.
Perl
$filepanel->SendMessage($target, $message);
Python
filepanel.SendMessage(target, message)
WasHidden
Called when user action hides the panel. (It is not called when you call Hide.)
Perl
$filepanel->WasHidden();
Python
filepanel.WasHidden()
CONSTANTS
Buttons
Perl
use HaikuR1::FilePanel qw(:file_panel_button)
Python
Python does not support export tags.
- B_CANCEL_BUTTON
- B_DEFAULT_BUTTON (the Save or Open button)
Modes
Perl
use HaikuR1::FilePanel qw(:file_panel_mode)
Python
Python does not support export tags.
- B_OPEN_PANEL
- B_SAVE_PANEL