Documentation | InterfaceKit | ListView
SYNOPSIS
Perl
use HaikuR1::ListView qw(B_SINGLE_SELECTION_LIST B_MULTIPLE_SELECTION_LIST B_POP_UP_BEHAVIOR B_NO_OP B_REPLACE_OP B_MOVE_OP B_SWAP_OP); my $listview = HaikuR1::ListView->new( frame => $frame, name => $name, type => $type, resizingMode => $resizingMode, flags => $flags, ); $window->AddChild($listview);
Python
from HaikuR1.InterfaceKit import ListView, B_SINGLE_SELECTION_LIST, B_MULTIPLE_SELECTION_LIST, B_POP_UP_BEHAVIOR, B_NO_OP, B_REPLACE_OP, B_MOVE_OP, B_SWAP_OP listview = ListView( frame = frame, name = name, type = type, resizingMode = resizingMode, flags = flags, ) window.AddChild(listview)
DESCRIPTION
Exposes the BListView
object.
For more information on ListView, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates a ListView.
Perl
HaikuR1::ListView->new( frame => $frame, name => $name, type => $type, resizingMode => $resizingMode, flags => $flags, ); HaikuR1::ListView->new($archive);
Python
ListView( frame = frame, name = name, type = type, resizingMode = resizingMode, flags = flags, ) ListView(archive)
frame
A Rect that indicates where on the parent Window the View should be. You should not specify a frame on a View that will be added to a parent which uses a Layout.
name
A string, the ListView's internal name.
type
An integer, one of the ListView type constants.
resizingMode
An integer, the resizing mode. (See the resizing mode constants.) Should only be specified when there is a frame. Defaults to
B_FOLLOW_NONE
.flags
An integer, view flags. (See the view flag constants.)
archive
A Message, contains an archived version of the ListView.
InvocationMessage
InvocationCommand
SetInvocationMessage
Gets or sets the Message that is sent when an item is invoked. (An item is invoked when the user double clicks on it or hits the space bar while the ListView has focus and the item is selected.
InvocationCommand
returns the invocation message's what
value.
SetInvocationMessage
can also be called as a hook.
Perl
$listview->InvocationMessage(); $listview->InvocationCommand(); $listview->SetInvocationMessage($message);
Python
listview.InvocationMessage() listview.InvocationCommand() listview.SetInvocationMessage(message)
message
A Message, the invocation message.
Item Information
Items
ItemAt
IndexOf
FirstItem
LastItem
HasItem
CountItems
IsEmpty
InvalidateItem
ItemFrame
These functions do what you expect.
Items
returns a native list.
Perl
$listview->Items($class); $listview->ItemAt($index, $class); $listview->IndexOf($point); $listview->IndexOf($item); $listview->FirstItem($class); $listview->LastItem($class); $listview->HasItem($item); $listview->CountItems(); $listview->InvalidateItem($index); $listview->ItemFrame($index); $listview->IsEmpty();
Python
listview.Items(class) listview.ItemAt(index, class) listview.IndexOf(point) listview.IndexOf(item) listview.FirstItem(class) listview.LastItem(class) listview.HasItem(item) listview.CountItems() listview.InvalidateItem(index) listview.ItemFrame(index) listview.IsEmpty()
class
Optional; a class for the native wrapper object returned by the method; defaults to
ListItem
. (SinceListItem
is not a fully functional class, you probably want to useStringItem
here, unless you create your own ListItem subclass.)index
An integer, the zero-based index of the item.
point
A Point, the location (in the ListView's coordinate space) of the desired item.
item
A ListItem, the item in question.
Item Maintenance
AddItem
AddList
RemoveItem
RemoveItems
MakeEmpty
These functions allow you to add and remove items. They can also be called as hooks.
Perl
$listview->AddItem($item, $index); $listview->AddList($newItems, $index); $listview->RemoveItem($item); $listview->RemoveItem($index); $listview->RemoveItems($index, $count); $listview->MakeEmpty();
Python
listview.AddItem(item, index) listview.AddList(newItems, index) listview.RemoveItem(item) listview.RemoveItem(index) listview.RemoveItems(index, count) listview.MakeEmpty()
item
A ListItem to add or remove.
newItems
A native list of items to add.
index
An integer, the index of the item to remove, or the position to insert the new item. Can be omitted when adding, in which case the new item or items will be added at the end of the list.
count
An integer, the number of items to remove; defaults to 1.
Item Operations
DoForEach
SortItems
SwapItems
MoveItem
ReplaceItem
These methods perform various operations on the items.
Perl
$listview->DoForEach($func, $arg); $listview->SortItems($cmp); $listview->SwapItems($a, $b); $listview->MoveItem($from, $to); $listview->ReplaceItem($index, $item);
Python
listview.DoForEach(func, arg) listview.SortItems(cmp) listview.SwapItems(a, b) listview.MoveItem(from, to) listview.ReplaceItem(index, item)
func
A function that will be called for each item. The item will be passed to the function. The function should return true to stop iterating over the items, false to continue iterating.
arg
An optional argument; if provided, it will be passed to the
DoForEach
function as a second parameter.cmp
A function that will be called to compare two items; the items will be passed as parameters. The function should return a negative number if the first item should be sorted before the second, zero if the two items are equivalent, and a positive number if the second item should come first.
a
,b
Integers, the indexes of the items to swap.
from
An integer, the index of the item to move.
to
An integer, the position to which the item should be moved.
index
An integer, the index of the item to replace.
item
A ListItem, the new item.
ListType
SetListType
Get or set the list type. SetListType
can also be called as a hook.
Perl
$listview->ListType(); $listview->SetListType($type);
Python
listview.ListType() listview.SetListType(type)
type
An integer, one of the ListView type constants.
Select
IsItemSelected
CurrentSelection
Deselect
DeselectAll
DeselectExcept
ScrollToSelection
These items do what you expect.
Even when the ListView is B_SINGLE_SELECTION_LIST
, multiple items can be
selected programatically.
Perl
$listview->Select($index, $extend); $listview->SelectMultiple($range, $extend); $listview->IsItemSelected($index); $listview->CurrentSelection($index); $listview->Deselect($index); $listview->DeselectAll(); $listview->DeselectExcept($exceptFrom, $exceptTo); $listview->ScrollToSelection();
Python
listview.Select(index, extend) listview.SelectMultiple(range, extend) listview.IsItemSelected(index) listview.CurrentSelection(index) listview.Deselect(index) listview.DeselectAll() listview.DeselectExcept(exceptFrom, exceptTo) listview.ScrollToSelection()
index
An integer, the index of the item to select or deselect.
CurrentSelection
takes an index into the set of selected items and returns an index into the set of all items.range
A two-item native list, the start and end indexes of the items to select.
extend
A boolean; if true, the current selection will be retained and the new items will be added to it; otherwise, the current selection will be replaced.
exceptFrom
,exceptTo
Integers, the starting and ending indexes of the items to remain selected.
Due to the way the bindings handle errors, if you
create a subclass and call Select on it, you will cause an error to
be signalled. (This happens only when you call Select
programmatically, not
when the user selects an item.)
To avoid this problem, use the following workarounds:
Perl
$Haiku::autodie = 0; $listview->Select($index); # OR eval { $listview->Select($index);
Python
try: listview.Select(0) except: pass
SelectionMessage
SelectionCommand
SetSelectionMessage
Gets or sets the Message that is sent when an item is selected.
SelectionCommand
returns the selection message's what
value.
SetSelectionMessage
can also be called as a hook.
Perl
$listview->SelectionMessage(); $listview->SelectionCommand(); $listview->SetSelectionMessage($message);
Python
listview.SelectionMessage() listview.SelectionCommand() listview.SetSelectionMessage(message)
message
A Message, the selection message.
HOOKS
DoMiscellaneous
Called for SwapItems, MoveItem, and ReplaceItem.
Perl
$listview->DoMiscellaneous($code, $data);
Python
listview.DoMiscellaneous(code, data)
code
An integer, one of the item operation constants.
data
A native map of information about the operations.
If the code is
B_REPLACE_OP
, the map will have an entryreplace
, which will be a map containing theindex
anditem
passed toReplaceItem
.If the code is
B_MOVE_OP
, the map will have an entrymove
, which will be a map containing thefrom
andto
passed toMoveItem
.If the code is
B_SWAP_OP
, the map will have an entryswap
, which will be a map containing thea
andb
passed toSwapItems
.
InitiateDrag
Called when the user begins to drag an item. Return true to allow the drag and drop operation, false to disallow it.
Perl
$listview->InitiateDrag($point, $itemIndex, $wasSelected);
Python
listview.InitiateDrag(point, itemIndex, wasSelected)
point
The Point at which the mouse was clicked.
itemIndex
The index of the item being dragged.
wasSelected
A boolean, indicates whether the item was already selected when the mouse click begain the drag.
SelectionChanged
Called when the selection is changed.
Perl
$listview->SelectionChanged();
Python
listview.SelectionChanged()
ARCHIVABLE INTERFACE
ListView
inherits the methods and hooks of Archivable.
HANDLER INTERFACE
ListView
inherits the methods and hooks of Handler.
VIEW INTERFACE
ListView
inherits the methods and hooks of View.
CONSTANTS
Types
Perl
use HaikuR1::ListView qw(:list_view_type)
Python
Python does not support export tags.
B_SINGLE_SELECTION_LIST
User may only select one item at a time.
B_MULTIPLE_SELECTION_LIST
User may select multiple items at the same time.
Operations
See DoMiscellaneous.
Perl
use HaikuR1::ListView qw(:ops)
Python
Python does not support export tags.
B_NO_OP
B_REPLACE_OP
B_MOVE_OP
B_SWAP_OP
SCRIPTING SUITE
The name of Menu's scripting suite is suite/vnd.Be-list-view
.
Properties
Item
B_COUNT_PROPERTIES
,B_EXECUTE_PROPERTY
Returns the number of selected items, or selects and invokes the specified items; when selecting, should be combined with a specifier to indicate the item(s) to invoke.
Selection
B_COUNT_PROPERTIES
,B_EXECUTE_PROPERTY
,B_GET_PROPERTY
,B_SET_PROPERTY
Counts, selects and invokes, gets, or sets the currently selected items. When selecting, should be combined with a specifier to indicate the item(s) to invoke. When setting, if no specifier is selected, will select all items. Also when setting, the
data
field of the Message should be a boolean indicating whether to select (true) or deselect (false).
Specifiers
Item
B_INDEX_SPECIFIER
,B_REVERSE_INDEX_SPECIFIER
,B_RANGE_SPECIFIER
,B_REVERSE_RANGE_SPECIFIER
Targets one or more ListItems by index or range.
Selection
B_INDEX_SPECIFIER
,B_REVERSE_INDEX_SPECIFIER
,B_RANGE_SPECIFIER
,B_REVERSE_RANGE_SPECIFIER
Targets items to be selected (or deselected) by index or range.
At the time if writing, the B_SET_PROPERTY
and B_EXECUTE_PROPERTY
operations were not yet implemented, except for Selection
with no
specifiers.
ListView also inherits the following suites: