Closed Bellisario closed 1 year ago
I have no clue what you are trying to do with "&ui.Window = unsafe { nil }" but it looks wrong and probably the reason your code doesn't work. Start with simpler examples that you can easily understand and the rest should come naturally.
@xandro0777 thanks for your answer. I looked for some other examples and found how to start properly.
Anyway, I found where is the bug: the usage of a textbox causes app crash without any error (at compile time and running).
For example, this simple code won't run on my machine because of the textbox (commenting it will run successfully):
import ui
[heap]
struct App {
mut:
text string
}
fn main() {
mut app := App{}
c := ui.column(
widths: ui.stretch
margin_: 5
spacing: 10
children: [
ui.textbox(
max_len: 20
width: 300
placeholder: 'Text here'
text: &app.text
is_focused: true
),
ui.button(text: 'Alert Textbox Output', on_click: app.btn_click, width: 150),
]
)
w := ui.window(
width: 450
height: 120
title: 'Textbox Bug'
children: [c]
)
ui.run(w)
}
fn (mut app App) btn_click(b voidptr) {
ui.message_box('Output: $app.text')
}
Same bug of #444.
Bug workaround with https://github.com/vlang/ui/issues/444#issuecomment-1193042155
V doctor:
What did you do?
v run .
and alsov . && <app>.exe
What did you expect to see?
I expected application didn't close just after started running (displaying window).
What did you see instead?
Application closes just after showing the window, making the program not usable.