API version 1
- ‐
R
CRS::Common::UI::TreeItem
parent¶
自身の親のツリーアイテムを示します。
最上位のツリーアイテムの場合 rootItemを返します。 rootItemの場合はnullを返します。
関連項目
child、TreeView.rootItemプロパティ
使用例
CRSダウンロード
Form TreeView_properties {
x = 0;
y = 0;
width = 800;
height = 600;
TreeView treeView1 {
x = 8;
y = 8;
width = 640;
height = 480;
# インデント幅を設定します
indentation=30;
function initializeTree(numDescendants)
{
var treeItems = new Array(numDescendants);
treeItems[0] = rootItem;
for (var index = 0; index < numDescendants; index ++) {
var parentItem = treeItems[Math.floor(Math.random() * index)];
var childTitle = ((parentItem.title == "") ? "item" : parentItem.title) + "-" + str(getNumChildren(parentItem));
treeItems[index + 1] = parentItem.append(childTitle);
}
}
function getNumChildren(item) {
var numItems = 0;
for (var child = item.child; child != null; child = child.next) {
numItems ++;
}
return numItems;
}
initializeTree(100);
rootItem.expandAll();
}
Button buttonSelectFirstVisibleItem {
x = 656;
y = 8;
width = 136;
height = 24;
title = "Select firstVisibleItem";
function onTouch(e) {
# 表示範囲の最初のアイテムを取得します
var item = ^.TreeView1.firstVisibleItem;
item.selected = true;
}
}
Button buttonSelectLastVisibleItem {
x = 656;
y = 40;
width = 136;
height = 24;
title = "Select lastVisibleItem";
function onTouch(e) {
# 表示範囲の最後のアイテムを取得します
var item = ^.TreeView1.lastVisibleItem;
item.selected = true;
}
}
Button buttonSelectItemNext {
x = 656;
y = 136;
width = 136;
height = 24;
title = "Select next";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムの次に位置する同階層のアイテムを取得します
var itemNext = item.next;
if (itemNext == null) {
print("Next item is null.");
return;
}
print("Next item is selected.");
itemNext.selected = true;
}
}
Button buttonSelectItemPrev {
x = 656;
y = 168;
width = 136;
height = 24;
title = "Select prev";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムの前に位置する同階層のアイテムを取得します
var itemPrev = item.prev;
if (itemPrev == null) {
print("Prev item is null.");
return;
}
print("Prev item is selected.");
itemPrev.selected = true;
}
}
Button buttonSelectItemChild {
x = 656;
y = 200;
width = 136;
height = 24;
title = "Select child";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムの最初の子アイテムを取得します
var itemChild = item.child;
if (itemChild == null) {
print("Child item is null.");
return;
}
print("Child item is selected.");
itemChild.selected = true;
}
}
Button buttonSelectItemParent {
x = 656;
y = 232;
width = 136;
height = 24;
title = "Select parent";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムの親アイテムを取得します
var itemParent = item.parent;
if (itemParent == null) {
print("Parent item is null.");
return;
}
print("Parent item is selected.");
itemParent.selected = true;
}
}
Button buttonSelectItemNextVisible {
x = 656;
y = 264;
width = 136;
height = 24;
title = "Select next visible";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムの次に表示されているアイテムを取得します
var itemNext = item.nextVisible;
if (itemNext == null) {
print("Next visible item is null.");
return;
}
print("Next visible item is selected.");
itemNext.selected = true;
}
}
Button buttonSelectItemPrevVisible {
x = 656;
y = 296;
width = 136;
height = 24;
title = "Select prev visible ";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムの前に表示されているアイテムを取得します
var itemPrev = item.prevVisible;
if (itemPrev == null) {
print("Prev visible item is null.");
return;
}
print("Prev visible item is selected.");
itemPrev.selected = true;
}
}
Button buttonEnsureVisible {
x = 656;
y = 104;
width = 136;
height = 24;
title = "Ensure visible";
function onTouch(e) {
var item = ^.TreeView1.selectedItem;
if (item == null) {
print("Selected item is null.");
return;
}
# 選択されたアイテムが表示されるようスクロール位置を調整します
item.ensureVisible();
}
}
}