Haiku API Bindings
ListView
Not logged in

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)

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)

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()

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 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)

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)

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()

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)

HOOKS

DoMiscellaneous

Called for SwapItems, MoveItem, and ReplaceItem.

Perl

$listview->DoMiscellaneous($code, $data);

Python

listview.DoMiscellaneous(code, data)

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)

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.

Operations

See DoMiscellaneous.

Perl

use HaikuR1::ListView qw(:ops)

Python

Python does not support export tags.

SCRIPTING SUITE

The name of Menu's scripting suite is suite/vnd.Be-list-view.

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: