simple/
simple.rs

1use fltk::{
2    app, enums,
3    prelude::{GroupExt, WidgetExt},
4    window,
5};
6use fltk_table::{SmartTable, TableOpts};
7
8fn main() {
9    let app = app::App::default().with_scheme(app::Scheme::Gtk);
10    let mut wind = window::Window::default().with_size(800, 600);
11
12    // We pass the rows and columns thru the TableOpts field
13    let mut table = SmartTable::default()
14        .with_size(790, 590)
15        .center_of_parent()
16        .with_opts(TableOpts {
17            rows: 30,
18            cols: 30,
19            editable: true,
20            ..Default::default()
21        });
22
23    wind.end();
24    wind.show();
25
26    // set the value at the row,column 4,5 to "another", notice that indices start at 0
27    table.set_cell_value(3, 4, "another");
28    assert_eq!(table.cell_value(3, 4), "another");
29
30    // To avoid closing the window on hitting the escape key
31    wind.set_callback(move |_| {
32        if app::event() == enums::Event::Close {
33            app.quit();
34        }
35    });
36
37    app.run().unwrap();
38}