int_table/
int_table.rs

1use fltk::{
2    app, enums, input,
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: 1000,
19            editable: true,
20            ..Default::default()
21        });
22
23    wind.end();
24    wind.show();
25
26    table
27        .input()
28        .as_mut()
29        .unwrap()
30        .set_type(input::InputType::Int);
31
32    // set the value at the row,column 4,5 to "another", notice that indices start at 0
33    table.set_cell_value(3, 4, "10");
34    assert_eq!(table.cell_value(3, 4), "10");
35
36    // To avoid closing the window on hitting the escape key
37    wind.set_callback(move |_| {
38        if app::event() == enums::Event::Close {
39            app.quit();
40        }
41    });
42
43    app.run().unwrap();
44}