質問

I have a dialog which contains multiple text item elements and a button. How can i retrieve the values and use them?

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

you can process a list altogether, applying to each element (a textitem object) a 'get text' operation

他のヒント

You must query the selection of the text_item by

get(NameItem, selection, SelNameItem),

If you use XPCE predicates, you can use NameItem?selection.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top