}
#[action]
- pub fn note_activated(&mut self, event: &ActionEvent) {
+ pub fn note_activated(&mut self, event: &mut ActionEvent) {
if let EventType::ListSelection(s) = event.event_type {
self.select_note_from(NoteSelectFrom::ListSelection(s));
+ if let Some(obj) = &mut event.obj {
+ obj.splitview_set_visible(0, false);
+ }
}
}
#[action]
pub fn new_notebook(&mut self, event: &ActionEvent) {
- if let Some(obj) = event.obj {
+ if let Some(obj) = &event.obj {
new_notebook_dialog(obj, &self.groups, self.backend.clone());
}
}
}
pub struct ActionEvent<'a> {
- pub obj: Option<&'a UiObject<NoAppData>>,
+ pub obj: Option<&'a mut UiObject<NoAppData>>,
pub event_type: EventType<'a>,
pub intval: i32,
pub set: bool
}
pub struct ActionEventWrapper<T> {
- pub callback: Box<dyn FnMut(&mut T, &ActionEvent)>,
+ pub callback: Box<dyn FnMut(&mut T, &mut ActionEvent)>,
pub target: *mut T
}
}
fn action_callback<F>(e: *const ffi::UiEvent, f: F)
-where F: FnOnce(&ActionEvent) {
+where F: FnOnce(&mut ActionEvent) {
unsafe {
let ev_int = ui_event_get_int(e);
let ev_set = ui_event_get_set(e) != 0;
let obj = if obj_ptr.is_null() {
None
} else {
- Some(&UiObject::from_ptr(obj_ptr))
+ Some(&mut UiObject::from_ptr(obj_ptr))
};
- let event = ActionEvent {
+ let mut event = ActionEvent {
obj: obj,
event_type: event_type,
intval: ev_int,
set: ev_set
};
- f(&event);
+ f(&mut event);
}
}
pub struct UntypedEventWrapper {
- pub callback: Box<dyn FnMut(&ActionEvent)>
+ pub callback: Box<dyn FnMut(&mut ActionEvent)>
}
pub extern "C" fn untyped_event_wrapper(e: *const ffi::UiEvent, data: *mut c_void) {
}
pub unsafe fn add_action<T, F>(&self, name: &str, f: F)
- where F: FnMut(&mut T, &event::ActionEvent) + 'static {
+ where F: FnMut(&mut T, &mut event::ActionEvent) + 'static {
// if this is a document context, use the document pointer as target
// otherwise it is a UiObject context, in that case we use the window_data as target
let doc_ptr = ui_context_document(self.ptr) as *mut T;
}
pub unsafe fn add_action_for_target<T, F>(&self, target_ptr: *mut T, name: &str, f: F)
- where F: FnMut(&mut T, &event::ActionEvent) + 'static {
+ where F: FnMut(&mut T, &mut event::ActionEvent) + 'static {
let wrapper = Box::new(ActionEventWrapper { callback: Box::new(f), target: target_ptr });
let ptr = self.reg_box(wrapper);
let cstr = CString::new(name).unwrap();
}
pub fn add_action_untyped<F>(&self, name: &str, f: F)
- where F: FnMut(&event::ActionEvent) + 'static {
+ where F: FnMut(&mut event::ActionEvent) + 'static {
unsafe {
let wrapper = Box::new(UntypedEventWrapper { callback: Box::new(f) });
let ptr = self.reg_box(wrapper);
}
pub fn add_action<F>(&mut self, name: &str, f: F)
- where F: FnMut(&mut T, &event::ActionEvent) + 'static {
+ where F: FnMut(&mut T, &mut event::ActionEvent) + 'static {
unsafe {
let wrapper = Box::new(ActionEventWrapper { callback: Box::new(f), target: self.get_data_ptr() });
let ptr = self.ctx.reg_box(wrapper);