d47081
(D47081)
December 7, 2024, 9:48pm
1
I’m using custom GObject with Factory for DropDown, but after change item property (used for some Label there) - it does not apply in UI until I hover the item (e.g. on bind
event)
What I forgot about, maybe some additional event listener wanted here?
d47081
(D47081)
December 7, 2024, 11:24pm
2
Yes, every custom property added has it own event listener, so I should connect it and process according to the app implementation.
item_gobject.connect_custom_property_name(|_|{});
UPD. found alternative solution with properties bind / sync in related subject:
Hi everyone. I have precisely the same issue as:
ColumnView, ListStore item changes
When a user edits a value in a ColumnView, I update values in the same row, in other columns. Changes in the “model” aren’t automatically sync’d to existing widgets. However if I scroll WAY past the row being edited ( and the widgets get recycled ), I can then scroll back and see the changes. But there must be some kind of signal I can emit to tell the widgets in a given row to “rebind”? Is there some way to tr…
Not sure it’s correct, but works, here is my implementation:
// ..
factory.connect_bind(|_, this| {
// Downcast requirements
let list_item = this.downcast_ref::<ListItem>().unwrap();
let item = list_item.item().and_downcast::<Item>().unwrap();
let child = list_item.child().and_downcast::<Box>().unwrap();
// Bind `title`
match child.first_child().and_downcast::<Label>() {
Some(label) => {
// defaults
label.set_label(&item.title());
label.set_css_classes(if item.is_active() { &["success"] } else { &[] });
// sync properties
item.bind_property("title", &label, "label").build();
item.bind_property("is-active", &label, "css-classes")
.transform_to(|_, is_active| {
if is_active {
Some(vec!["success".to_string()])
} else {
Some(vec![])
}
})
.build();
}
None => todo!(),
};
// ..
system
(system)
Closed
January 6, 2025, 11:24pm
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.