ComboBox (クラス)
public ComboBox {inherits {BaseComboBox String}}
インポート元: CURL.GUI.STANDARD. package 内で定義されています CURL.GUI.CONTROLS.

ComboBox コントロールを実装します。このコントロールは、編集可能なテキスト フィールドと組み合わされた選択可能な値のリストです。

説明

ComboBox は、編集可能なテキスト フィールド内に 1 つの値を示します。ユーザーはこのコントロールの右側のボタンをクリックして、有効な値の選択可能なリストを表示できます。ユーザーはコントロールがフォーカスを得たときに下矢印キーを押して、リストを表示することもできます。ユーザーがリスト内のアイテムをクリックして値を選択すると、その値が編集可能なテキスト フィールドに表示され、ユーザーはその値を編集または消去できます。

次の例は、標準の ComboBox を示しています。


{ComboBox
    "Antelope", "Llama", "Horse",
    value="Antelope"
}

プログラミング注意事項

ComboBox のリスト アイテムの値がアイテム自体と同じである必要はありません。たとえば、明示的な値と Visual のペアを保持する ListItem を指定して ComboBox を作成できます。ペアの Visual コンポーネントは、Curl 社で定義された Visual サブクラスのインスタンスであることが必要です。独自のサブクラスを作成する場合、clone-appearance メソッドを実装する必要があります。

別の方法として、値を与えると ListItem を生成する 1 つのプロシージャを指定することができます。選択した値のテキストは常にテキスト フィールドに表示されますが、Visual は表示されません。

これは可能ですが推奨されていません。その理由は、リスト内の値を選択するとテキスト フィールドに別の値が表示されることになり、ユーザーが混乱するためです。

カスタム ListItem の作成方法を示す例については、DropdownList を参照してください。

予期されたイベント

ValueChanged: ユーザーが新しい値を選択したとき、またはユーザーがテキスト フィールドのテキストを変更したとき、ComboBox.set-value-with-events が呼び出されたときに発生します。
ValueFinished: ValueChanged イベントが発生した直後に、新しい値をユーザーが選択するかプログラムを使って設定すると発生します。ただし、ユーザーがテキスト フィールドに入力した後では発生しません。
Action: ComboBox にキー フォーカスがある状態でユーザーが Enter キーを押すと発生します。
Commit: Dialog.commit が呼び出されたときに Dialog によって送られます。

ビジュアル テスト

このクラスは、CurlDropdown ビジュアル テスト タイプを実装します。
すべての Visual によってサポートされる既定のビジュアル テスト アクションの他に、このクラスのオブジェクトは次のアクションをサポートします。
アクション 引数 説明
Select item:Stringitem アイテムを選択します。
すべての Visual によってサポートされる既定のビジュアル テスト プロパティの他に、このクラスのオブジェクトは次のビジュアル テスト プロパティをサポートします。
プロパティ 説明
items count:int選択対象のアイテムの数です。
value:String コントロールの現在値です。

コンストラクタ
default:このオブジェクトを作成します。
コンストラクタ public {ComboBox.default
value:#String = null,
data-model:ListModel = {DefaultListModel},
prompt:#String = null,
max-chars:int = -1,
dropdown-height:Distance = 0pt,
list-item-creation-proc:{proc-type {val:any}:ListItem} = ListModelControl.default-list-item-creation-proc,
ui-object:#ComboBoxUI = null,
...
}

プロパティ
editable?:ユーザーがテキスト コントロールに値を入力できるかどうかを指定します。既定では、true です。
ローカル オプション public ComboBox.editable?:bool =true
form-value:コントロールを含む HttpForm と共に送信されるコントロールの値。
アクセサ public ComboBox.form-value:any
has-value?:この Control は値を持っているかどうかを示します。
アクセサ public final ComboBox.has-value?:bool
max-chars:テキスト フィールドに入力される最大文字数。既定値は -1 です。
アクセサ public ComboBox.max-chars:int
セッター public ComboBox.max-chars:int
prompt:コントロールに値がないときに表示される String
アクセサ public ComboBox.prompt:#String
セッター public ComboBox.prompt:#String
style-element:スタイリングの目的のための、この Visual の "要素" や "型" です。
アクセサ public ComboBox.style-element:String
value:このコントロールの値。
アクセサ public ComboBox.value:String
セッター public ComboBox.value:String
プロパティ 継承 BaseComboBox: dropdown-height, dropdown-width, pending-value?, selected-index, selected-item, test-type-name
プロパティ 継承 ListModelControl: data-model, for-loop-count, items, list-item-creation-proc, list-item-selected-background, list-item-selected-foreground, list-items, size
プロパティ 継承 MultiUIControlFrame: _ui-object, _ui-set-locally?, control-appearance-changeable?, display-context, focus-object, look-and-feel, ui-object
プロパティ 継承 ValueControl-of: value-as-any, value-type
プロパティ 継承 ControlFrame: color, control-color, control-content-background, enabled?, font-family, font-size, font-style, font-weight, text-breakable?, text-line-through?, text-preserve-whitespace?, text-underline?, visible?
プロパティ 継承 BaseFrame: child, clonable-class?, completely-clonable-children?, graphical-children, halign-spec, hstretch?-spec, ordered-children, reverse-ordered-children, valign-spec, vstretch?-spec, width-first?
プロパティ 継承 CommandBinding: bound-command, bound-command-impl
プロパティ 継承 Control: control-container, dialog, focus-skin, form, skin
プロパティ 継承 ActiveTraversor: _active-traversal-container, active-traversal-container, mnemonic, tab-index, takes-focus?, valid?, validation-result
プロパティ 継承 GetBoundsBox: layout-locally-valid?, layout-valid?
プロパティ 継承 EventTarget: event-handlers
プロパティ 継承 Visual: _style-element, cursor, data-source, dragee, input-method-enabled?, input-method-keyboard-mode, name, options, options-present-here, style-class, style-manager, style-options, test-description, test-name, test-parent?, test-visible?, tooltip, user-data
プロパティ 継承 Box: clip-child-shadows?
プロパティ 継承 Graphic: avoid-page-break?, background, border-color, border-spec, border-style, border-width, cell-border-spec, cell-border-width, cell-margin, discrete-select-in-range?, graphic-selectable, height, horigin, is-paginating?, layout, margin, opaque-to-events?, option-parent, outside-margin, pagination-state, parent, selection-context, shadow-color, shadow-spec, vorigin, width
プロパティ 継承 DataBindingTarget: data-binding-context, data-bindings
プロパティ 継承 OptionListInterface: option-register-proc, registered-option-keys

メソッド
create-default-ui-object:このオブジェクトに適切な UI オブジェクトを作成します。
protected {ComboBox.create-default-ui-object}:ControlUI
select-index:指定したインデックスの ListItem を選択します。
public {ComboBox.select-index index:int}:void
select-index-with-events:指定したインデックスの ListItem を選択し、必要に応じて ValueChangedValueFinished イベントを発生させます。
public {ComboBox.select-index-with-events i:int}:void
set-value-with-events:コントロールの値を設定し、後で ValueChanged (該当する場合) および ValueFinished のイベントを発生させます。インタラクティブに値を設定するユーザーをビジュアルなしでシミュレーションすることになります。
public {ComboBox.set-value-with-events val:String}:void
unset-value:値をコントロールの既定値に戻すか、初期化されていない状態があればその状態に戻します。
public {ComboBox.unset-value}:void
メソッド 継承 BaseComboBox: add-from-init-args, deselect-all-items, get-test-property, notify-interval-added, notify-interval-changed, notify-interval-removed, notify-item-selected, react-to-state-change, select-index-internal, test-run
メソッド 継承 MultiUIValueControlFrame-of: unset-property
メソッド 継承 ListModelControl: append, clear-items, find, get, insert, rebuild-from-data-model, remove, set
メソッド 継承 MultiUIControlFrame: generate-ui-object, handle-look-and-feel-change, handle-observer-message, on-focus-in, option-changed, option-lookup-here, option-propagate-notify, react-to-visual-change, request-key-focus, set-layout
メソッド 継承 ControlFrame: become-active, clear
メソッド 継承 BaseFrame: add-internal, after-reposition, allocate-layout-object, attempt-revalidate-layout, before-reposition, clone-appearance-helper, compute-child-bounds, compute-parent-elastic, constrain-height, constrain-width, draw, end-pagination, get-height-preference, get-text, get-width-preference, install-child-bounds, internal-remove-child, note-attached, note-detaching, notify-option-children, paginate, pick-child, propagate-request-layout, register-options, set-size
メソッド 継承 Control: on-pointer-press
メソッド 継承 BasicBox: contains-point?, find-graphic-at, handle-crossing, on-pointer-envelope-event, pointer-enter-occurred, pointer-leave-occurred
メソッド 継承 StandardActiveTraversor: become-active-from-traversal, fire-event-at-container, handle-mnemonic, on-key-press
メソッド 継承 Observer: observe, stop-observing
メソッド 継承 GuiEventTarget: handle-event, on-action, on-cancel-mode, on-command-changed, on-commit, on-composition-change-event, on-composition-result-event, on-context-menu-event, on-current-record-change-request, on-current-record-changed, on-destroy-notify, on-destroy-requested, on-drag-over, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-out, on-grab-release, on-gui-event, on-input-method-event, on-key-event, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-release, on-pointer-scroll, on-raw-key-event, on-raw-key-press, on-raw-key-release, on-reset, on-selectable-added, on-selectable-removed, on-selection-changed, on-selection-context-activated, on-selection-context-deactivated, on-selection-event, on-start-composition-event, on-start-event, on-stop-event, on-view-activate, on-view-deactivate, on-window-close, remove-event-handlers-for-event-class
メソッド 継承 ActiveTraversor: mark-invalid, mark-valid
メソッド 継承 GetBoundsBox: get-bounds, get-elastic-bounds-into, get-nonparent-bounds-into, request-layout, validate-layout
メソッド 継承 EventTarget: accepts-event-class?, add-event-handler, event-handler-present?, remove-event-handler, verify-event
メソッド 継承 Visual: add, add-option, add-style-option, animate, change-cursor, clonable-appearance?, clone-appearance, get-focus-manager, get-layout-context, get-test-parent, get-view, maybe-fire-attach-event, maybe-fire-detach-event, non-keyword-init-arg, note-caret-position, on-drag-leave, on-pointer-leave, pop-cursor, prepare-test-object, prepare-test-parent, push-cursor, quantize-width, release-key-focus, remove-option, remove-style-option, scroll-to-include, test-record, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-to-display-coordinates, transform-to-graphical-root-coordinates
メソッド 継承 Box: compare-children, find-test-children, get-delimited-child-text-selection, get-range-as-selected-text, get-visible-rect-in-root-into, graphical-child-visible-at, make-gui-mark, search-next-here, search-prev-here
メソッド 継承 BasicEventTarget: enqueue-event
メソッド 継承 GraphicOptions: any-to-Distance, get-display-context
メソッド 継承 Graphic: create-pagination-state, detach, draw-range-as-selected, draw-shadow, find-ancestor, find-graphical-ancestor, fire-inferior-crossing-event, get-graphical-root, get-origin-in-graphical-ancestor, get-origin-in-root, get-pagination-state, get-top-left-in-ancestor, get-visible-bounds-into, on-drag-enter, on-inspection, on-pointer-enter, paint-with-decorations, replace-with, request-draw, request-draw-rect, request-pointer-trace, search-next, search-prev, start-pagination, xy-offset-to
メソッド 継承 DataBindingTarget: add-data-binding, get-data-binding, refresh-data-binding, remove-data-binding, update-data-binding, validate-data-binding
メソッド 継承 OptionListInterface: change-option-parent-notify, clone-options, get-option, get-option-by-name, keyword-init-arg, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-change-notify, option-lookup, option-set?, propagate-option-change, remove-styles, set-option-by-name, set-style-option-by-name, unset-option-by-name, unset-style-option-by-name
メソッド 継承 InitRestArgParser: process-rest-args
メソッド 継承 Object: object-describe, object-describe-for-debugging, object-serialize



コンストラクタ詳細
default (コンストラクタ)
public {ComboBox.default
value:#String = null,
data-model:ListModel = {DefaultListModel},
prompt:#String = null,
max-chars:int = -1,
dropdown-height:Distance = 0pt,
list-item-creation-proc:{proc-type {val:any}:ListItem} = ListModelControl.default-list-item-creation-proc,
ui-object:#ComboBoxUI = null,
...
}

このオブジェクトを作成します。

value: ComboBox.value を参照してください。
data-model: ComboBox.data-model を参照してください。
prompt: ComboBox.prompt を参照してください。
max-chars: ComboBox.max-chars を参照してください。
dropdown-height: ComboBox.dropdown-height を参照してください。
list-item-creation-proc: ComboBox.list-item-creation-proc を参照してください。
ui-object: このコントロールが使用する特定の ComboBoxUI。詳細については、ComboBox.ui-object を参照してください。
...: 追加オプションの仕様とイベント ハンドラ。



プロパティ詳細
editable? (ローカル オプション)
public ComboBox.editable?:bool =true

ユーザーがテキスト コントロールに値を入力できるかどうかを指定します。既定では、true です。

注意事項

ComboBox が編集可能でない場合、値のリストで選択するか、キーボードの上や下キーを押すことでユーザーは値を変更できます。
導入: バージョン 6.0


form-value (アクセサ)
アクセサ public ComboBox.form-value:any

コントロールを含む HttpForm と共に送信されるコントロールの値。

説明

この実装は ComboBox.value の値を返します。


has-value? (アクセサ)
アクセサ public final ComboBox.has-value?:bool

この Control は値を持っているかどうかを示します。

説明

ValueControl は通常はこのゲッターに true を返し、これはこのメソッドの既定の実装になります。ただし特定のタイプの ValueControlfalse を返して、最初の値のない状態にあることを示します。

たとえば、TextFieldComboBox はそれらの値がプログラミングで、またはインタラクティブに設定されておらず、プロンプト を示している場合に false を返します。

RadioButton が選択されていない RadioFramefalse を返す必要があります。

一方、RadioButtonCheckButton などの多くのコントロールは、そのような初期化されていない状態ではないため、つねに true を返します。

has-value? が false のときに ValueControl.value-as-any ゲッターが返す値はクラスに依存することに注意してください。詳細については、各クラスのドキュメントを参照してください。


max-chars (アクセサ)
アクセサ public ComboBox.max-chars:int
セッター public ComboBox.max-chars:int

テキスト フィールドに入力される最大文字数。既定値は -1 です。

プログラミング注意事項

上限に達すると、テキスト フィールドに文字の入力や切り取り / 貼り付けができなくなります。値 -1 は、入力できる文字数の制約がないことを表します。このプロパティを設定した結果として、ComboBox.unset-value によりコントロールの値が設定解除されます。


prompt (アクセサ)
アクセサ public ComboBox.prompt:#String
セッター public ComboBox.prompt:#String

コントロールに値がないときに表示される String

プログラミング注意事項

通常、"色を選択してください" など、ユーザーに選択操作を求めることを目的としています。プロンプトを指定しない場合、ComboBox.has-value?false のときにはコントロールは空欄です。


style-element (アクセサ)
アクセサ public ComboBox.style-element:String

スタイリングの目的のための、この Visual の "要素" や "型" です。

説明

この実装によって Visual._style-elementの値が返されますが、通常は定数を返すためにオーバーライドされます。

オーバーライド

Visual のサブクラスのスタイルが他のオブジェクトと異なる場合、このゲッターは適切な文字列を返すようにオーバーライドされる必要があります。 慣例では,この文字列はクラス名または、オブジェクトを生成するマークアップの名前です。
オーバーライドでは、空の文字列でないかぎり、self._style-elementを返さなければなりません。
導入: バージョン 6.0


value (アクセサ)
アクセサ public ComboBox.value:String
セッター public ComboBox.value:String

このコントロールの値。

説明

String ComboBox.max-chars より長い値を設定すると、エラーになります。この値が設定されると、コントロールがすでに同じ値を持つ下位アイテムを選択している場合を除き、この値を持つ最初の SelectableItem が選択されます。

文字列がコントロール内の選択可能なアイテムの中に見つからない場合、アイテムは選択されず、新しい文字列が表示されてコントロールの値になります。





メソッド詳細
create-default-ui-object (メソッド)
protected {ComboBox.create-default-ui-object}:ControlUI

このオブジェクトに適切な UI オブジェクトを作成します。

説明

このメソッドは、現在の LookAndFeel がこのコントロールの UI オブジェクトを指定しない場合にのみ使用されます。


select-index (メソッド)
public {ComboBox.select-index index:int}:void

指定したインデックスの ListItem を選択します。

i: 指定したインデックス。

説明

i が範囲外の場合はエラーがスローされます。


select-index-with-events (メソッド)
public {ComboBox.select-index-with-events i:int}:void

指定したインデックスの ListItem を選択し、必要に応じて ValueChangedValueFinished イベントを発生させます。

i: 指定したインデックス。

説明

これは事実上 BaseComboBox.set-value-with-events による値の設定と同じになりますが、値の代わりにインデックスの指定が可能です。


set-value-with-events (メソッド)
public {ComboBox.set-value-with-events val:String}:void

コントロールの値を設定し、後で ValueChanged (該当する場合) および ValueFinished のイベントを発生させます。インタラクティブに値を設定するユーザーをビジュアルなしでシミュレーションすることになります。

val: コントロールに設定される値。

説明

このメソッドは、最初に set でコントロールの値を設定し、次にイベントを発生させます。


unset-value (メソッド)
public {ComboBox.unset-value}:void

値をコントロールの既定値に戻すか、初期化されていない状態があればその状態に戻します。

説明

詳細については、ValueControl.has-value? を参照してください。