Wireup context menu item clicks
This commit is contained in:
parent
65f9811db3
commit
b04ca73641
|
@ -20,4 +20,5 @@
|
|||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum UIEvent {
|
||||
TrayIconClick,
|
||||
ContextMenuClick(u32),
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ const MAX_FILE_PATH: usize = 260;
|
|||
const MAX_ICON_COUNT: usize = 3;
|
||||
|
||||
const UI_EVENT_TYPE_ICON_CLICK: i32 = 1;
|
||||
//const UI_EVENT_TYPE_CONTEXT_MENU_CLICK: i32 = 2;
|
||||
const UI_EVENT_TYPE_CONTEXT_MENU_CLICK: i32 = 2;
|
||||
|
||||
// Take a look at the native.h header file for an explanation of the fields
|
||||
#[repr(C)]
|
||||
|
@ -56,6 +56,7 @@ pub struct RawUIOptions {
|
|||
#[repr(C)]
|
||||
pub struct RawUIEvent {
|
||||
pub event_type: i32,
|
||||
pub context_menu_id: u32,
|
||||
}
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
|
@ -326,10 +327,12 @@ impl Win32Remote {
|
|||
impl From<RawUIEvent> for Option<UIEvent> {
|
||||
fn from(raw: RawUIEvent) -> Option<UIEvent> {
|
||||
match raw.event_type {
|
||||
// Keyboard events
|
||||
UI_EVENT_TYPE_ICON_CLICK => {
|
||||
return Some(UIEvent::TrayIconClick);
|
||||
}
|
||||
UI_EVENT_TYPE_CONTEXT_MENU_CLICK => {
|
||||
return Some(UIEvent::ContextMenuClick(raw.context_menu_id));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,12 @@ LRESULT CALLBACK ui_window_procedure(HWND window, unsigned int msg, WPARAM wp, L
|
|||
|
||||
if (flags == 0)
|
||||
{
|
||||
std::cout << "click menu" << std::flush;
|
||||
// TODO: click
|
||||
//context_menu_click_callback(manager_instance, (int32_t)idItem);
|
||||
event.event_type = UI_EVENT_TYPE_CONTEXT_MENU_CLICK;
|
||||
event.context_menu_id = (uint32_t) idItem;
|
||||
if (variables->event_callback && variables->rust_instance)
|
||||
{
|
||||
variables->event_callback(variables->rust_instance, event);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int32_t event_type;
|
||||
uint32_t context_menu_id;
|
||||
} UIEvent;
|
||||
|
||||
typedef void (*EventCallback)(void * self, UIEvent data);
|
||||
|
|
Loading…
Reference in New Issue
Block a user