[REBOL] Re: Request/ok
From: greggirwin:mindspring at: 13-Jul-2003 22:51
Hi patrick,
p> Is it possible to display more than one line with request/ok ?
p> I have tried:
p> request/ok "Text 1^(line)Text 2"
p> But it seems to ignore the ^(line). Any clue?
You probably need to use the source and add an 'as-is facet to the
text face it uses in the layout. See below.
-- Gregg
request: func [
"Requests an answer to a simple question."
str [string! block! object! none!]
/offset xy
/ok
/only
/confirm
/type icon [word!] {Valid values are: alert, help (default), info, stop}
/timeout time
/local lay result msg y n c width f
][
icon: any [icon all [none? icon any [ok timeout] 'info] 'help]
lay: either all [object? str in str 'type str/type = 'face] [str] [
if none? str [str: "What is your choice?"]
set [y n c] ["Yes" "No" "Cancel"]
if confirm [c: none]
if ok [y: "OK" n: c: none]
if only [y: n: c: none]
if block? str [
str: reduce str
set [str y n c] str
foreach n [str y n c] [
if all [found? get n not string? get n] [set n form get n]
]
]
width: any [all [200 >= length? str 280] to-integer (length?str) - 200 / 50 * 20 + 280]
; Change #1
layout [f: text as-is bold to-pair reduce [width 1000] str]
img: switch/default :icon [
info [info.gif]
alert [exclamation.gif]
stop [stop.gif]
] [help.gif]
result: copy [
backcolor base-color
across
at 0x0
origin 15x10
image img
pad 0x12
guide
; Change #2
msg: text as-is bold black copy str to-pair reduce [width -1] return
pad 4x12
]
if y [append result [btn-enter 60 y #"Y" [result: yes hide-popup]]]
if n [append result [btn 60 n #"N" [result: no hide-popup]]]
if c [append result [btn-cancel 60 c escape [result: none hide-popup]]]
layout result
]
result: none
either offset [inform/offset/timeout lay xy time] [inform/timeout lay time]
result
]