我有一个对话框,其中包含多个文本项元素和一个按钮。我怎样才能检索值并使用它们?
new(D, dialog('Add a recipe')),
send(D, append(new(NameItem, text_item('Name')))),
send(D, append(new(InstItem, text_item('Instruction')))),
send(D, append(new(IngrItem, text_item('Ingredients')))),
send(D, append(new(TimeItem, text_item('Time')))),
send(D, append(button('Store', message(D, return, '1')))),
get(D, confirm, Rvalue),
write(NameItem), nl,
write(InstItem), nl,
write(IngrItem), nl,
write(TimeItem), nl,
free(D),
test :-
new(D, dialog('Add a recipe')),
send(D, append(new(NameItem, text_item('Name')))),
send(D, append(new(InstItem, text_item('Instruction')))),
send(D, append(new(IngrItem, text_item('Ingredients')))),
send(D, append(new(TimeItem, text_item('Time')))),
send(D, append(button('Store', message(D, return, '1')))),
send(D, show(true)),
get(D, confirm, _Rvalue),
maplist(getv, [NameItem, InstItem, IngrItem, TimeItem]),
free(D).
getv(T) :- get(T, selection, V), writeln(V).
您可以完全处理列表,对每个元素(textitem对象)应用"获取文本"操作
您必须通过以下方式查询text_item的选择
get(NameItem, selection, SelNameItem),
如果使用 XPCE 谓词,则可以使用 NameItem?选择。