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