Skip to content

Commit a49ac0a

Browse files
committed
Rename menu context methods from ShowAsContextMenu to Open
Refactored all menu context menu methods and related documentation to use 'Open' and 'OpenAt' instead of 'ShowAsContextMenu' for clarity and consistency. Updated C/C++ APIs, platform-specific implementations, and example usages to reflect the new naming convention.
1 parent 7a9f15c commit a49ac0a

File tree

12 files changed

+50
-50
lines changed

12 files changed

+50
-50
lines changed

examples/menu_c_example/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ int main() {
172172
printf("Triggering checkbox item after removing click listener...\n");
173173
native_menu_item_trigger(checkbox_item);
174174

175-
// Show menu as context menu (this may not work in console applications)
176-
printf("\n=== Attempting to Show Context Menu ===\n");
175+
// Open menu as context menu (this may not work in console applications)
176+
printf("\n=== Attempting to Open Context Menu ===\n");
177177
printf("Note: Context menu display may not work in console applications\n");
178178

179-
if (native_menu_show_as_context_menu(menu, 100, 100)) {
180-
printf("Context menu shown successfully\n");
179+
if (native_menu_open_at(menu, 100, 100)) {
180+
printf("Context menu opened successfully\n");
181181
} else {
182-
printf("Failed to show context menu (expected in console app)\n");
182+
printf("Failed to open context menu (expected in console app)\n");
183183
}
184184

185185
// Test additional functionality

examples/menu_example/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ int main() {
101101
std::cout << "Triggering exit item..." << std::endl;
102102
exitItem->Trigger();
103103

104-
// Show menu as context menu (this may not work in console applications)
105-
std::cout << "\n=== Attempting to Show Context Menu ===" << std::endl;
104+
// Open menu as context menu (this may not work in console applications)
105+
std::cout << "\n=== Attempting to Open Context Menu ===" << std::endl;
106106
std::cout << "Note: Context menu display may not work in console applications" << std::endl;
107107

108108
// Try to show at screen coordinates (100, 100)
109-
if (menu->ShowAsContextMenu(100, 100)) {
110-
std::cout << "Context menu shown successfully" << std::endl;
109+
if (menu->Open(100, 100)) {
110+
std::cout << "Context menu opened successfully" << std::endl;
111111
} else {
112-
std::cout << "Failed to show context menu (expected in console app)" << std::endl;
112+
std::cout << "Failed to open context menu (expected in console app)" << std::endl;
113113
}
114114

115115
// Demonstrate submenu

examples/tray_icon_example/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ int main() {
131131
std::cout << "Tray icon example is now running!" << std::endl;
132132
std::cout << "Try clicking on the tray icon:" << std::endl;
133133
std::cout << "- Left click: Single click" << std::endl;
134-
std::cout << "- Right click: Shows context menu" << std::endl;
134+
std::cout << "- Right click: Opens context menu" << std::endl;
135135
std::cout << "- Double click: Quick double click" << std::endl;
136136
std::cout << "- Context menu: Right-click to see options including Exit" << std::endl;
137137
std::cout << "The application will run for 60 seconds, or until you click Exit." << std::endl;

src/capi/menu_c.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,25 +884,25 @@ native_menu_item_t native_menu_find_item_by_text(native_menu_t menu,
884884
}
885885
}
886886

887-
bool native_menu_show_as_context_menu(native_menu_t menu, double x, double y) {
887+
bool native_menu_open_at(native_menu_t menu, double x, double y) {
888888
if (!menu)
889889
return false;
890890

891891
try {
892892
auto menu_ptr = static_cast<Menu*>(menu);
893-
return menu_ptr->ShowAsContextMenu(x, y);
893+
return menu_ptr->Open(x, y);
894894
} catch (...) {
895895
return false;
896896
}
897897
}
898898

899-
bool native_menu_show_as_context_menu_default(native_menu_t menu) {
899+
bool native_menu_open(native_menu_t menu) {
900900
if (!menu)
901901
return false;
902902

903903
try {
904904
auto menu_ptr = static_cast<Menu*>(menu);
905-
return menu_ptr->ShowAsContextMenu();
905+
return menu_ptr->Open();
906906
} catch (...) {
907907
return false;
908908
}

src/capi/menu_c.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,22 +503,22 @@ FFI_PLUGIN_EXPORT
503503
native_menu_item_t native_menu_find_item_by_text(native_menu_t menu, const char* text);
504504

505505
/**
506-
* Show the menu as a context menu at specified coordinates
506+
* Open the menu as a context menu at specified coordinates
507507
* @param menu The menu
508508
* @param x The x-coordinate in screen coordinates
509509
* @param y The y-coordinate in screen coordinates
510-
* @return true if menu was shown successfully, false otherwise
510+
* @return true if menu was opened successfully, false otherwise
511511
*/
512512
FFI_PLUGIN_EXPORT
513-
bool native_menu_show_as_context_menu(native_menu_t menu, double x, double y);
513+
bool native_menu_open_at(native_menu_t menu, double x, double y);
514514

515515
/**
516-
* Show the menu as a context menu at default location
516+
* Open the menu as a context menu at default location
517517
* @param menu The menu
518-
* @return true if menu was shown successfully, false otherwise
518+
* @return true if menu was opened successfully, false otherwise
519519
*/
520520
FFI_PLUGIN_EXPORT
521-
bool native_menu_show_as_context_menu_default(native_menu_t menu);
521+
bool native_menu_open(native_menu_t menu);
522522

523523
/**
524524
* Close the menu if it's currently showing

src/menu.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ class MenuItem : public EventEmitter, public NativeObjectProvider {
544544
* std::cout << "Menu opened" << std::endl;
545545
* });
546546
*
547-
* // Show as context menu
548-
* fileMenu->ShowAsContextMenu(100, 100);
547+
* // Open as context menu
548+
* fileMenu->Open(100, 100);
549549
* ```
550550
*/
551551
class Menu : public EventEmitter, public NativeObjectProvider {
@@ -721,26 +721,26 @@ class Menu : public EventEmitter, public NativeObjectProvider {
721721
* Shows the menu at the given position and waits for user interaction.
722722
* The menu will close when the user clicks outside of it or selects an item.
723723
*
724-
* @param x The x-coordinate in screen coordinates where to show the menu
725-
* @param y The y-coordinate in screen coordinates where to show the menu
726-
* @return true if the menu was successfully shown, false otherwise
724+
* @param x The x-coordinate in screen coordinates where to open the menu
725+
* @param y The y-coordinate in screen coordinates where to open the menu
726+
* @return true if the menu was successfully opened, false otherwise
727727
*
728728
* @example
729729
* ```cpp
730-
* // Show context menu at cursor position
731-
* menu->ShowAsContextMenu(mouse_x, mouse_y);
730+
* // Open context menu at cursor position
731+
* menu->Open(mouse_x, mouse_y);
732732
* ```
733733
*/
734-
bool ShowAsContextMenu(double x, double y);
734+
bool Open(double x, double y);
735735

736736
/**
737737
* @brief Display the menu as a context menu at the current cursor position.
738738
*
739739
* Shows the menu at the current mouse cursor location.
740740
*
741-
* @return true if the menu was successfully shown, false otherwise
741+
* @return true if the menu was successfully opened, false otherwise
742742
*/
743-
bool ShowAsContextMenu();
743+
bool Open();
744744

745745
/**
746746
* @brief Programmatically close the menu if it's currently showing.

src/platform/linux/menu_linux.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ std::shared_ptr<MenuItem> Menu::FindItemByText(const std::string& text, bool cas
373373
return nullptr;
374374
}
375375

376-
bool Menu::ShowAsContextMenu(double x, double y) {
376+
bool Menu::Open(double x, double y) {
377377
if (pimpl_->gtk_menu_) {
378378
pimpl_->visible_ = true;
379379
gtk_menu_popup_at_pointer(GTK_MENU(pimpl_->gtk_menu_), nullptr);
@@ -382,8 +382,8 @@ bool Menu::ShowAsContextMenu(double x, double y) {
382382
return false;
383383
}
384384

385-
bool Menu::ShowAsContextMenu() {
386-
return ShowAsContextMenu(0, 0); // GTK will position at pointer
385+
bool Menu::Open() {
386+
return Open(0, 0); // GTK will position at pointer
387387
}
388388

389389
bool Menu::Close() {

src/platform/macos/menu_macos.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ - (void)menuDidClose:(NSMenu *)menu {
579579
return nullptr;
580580
}
581581

582-
bool Menu::ShowAsContextMenu(double x, double y) {
582+
bool Menu::Open(double x, double y) {
583583
NSPoint point = NSMakePoint(x, y);
584584

585585
// Convert screen coordinates to window coordinates if needed
@@ -606,9 +606,9 @@ - (void)menuDidClose:(NSMenu *)menu {
606606
return true;
607607
}
608608

609-
bool Menu::ShowAsContextMenu() {
609+
bool Menu::Open() {
610610
NSPoint mouseLocation = [NSEvent mouseLocation];
611-
return ShowAsContextMenu(mouseLocation.x, mouseLocation.y);
611+
return Open(mouseLocation.x, mouseLocation.y);
612612
}
613613

614614
bool Menu::Close() {

src/platform/macos/tray_icon_macos.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ @interface TrayIconMenuDelegate : NSObject <NSMenuDelegate>
255255
}
256256

257257
// Open the context menu at the specified coordinates
258-
return pimpl_->context_menu_->ShowAsContextMenu(x, y);
258+
return pimpl_->context_menu_->Open(x, y);
259259
}
260260

261261
bool TrayIcon::OpenContextMenu() {

src/platform/windows/menu_windows.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ std::shared_ptr<MenuItem> Menu::FindItemByText(const std::string& text,
529529
return nullptr;
530530
}
531531

532-
bool Menu::ShowAsContextMenu(double x, double y) {
532+
bool Menu::Open(double x, double y) {
533533
pimpl_->visible_ = true;
534534

535535
POINT pt = {static_cast<int>(x), static_cast<int>(y)};
@@ -545,10 +545,10 @@ bool Menu::ShowAsContextMenu(double x, double y) {
545545
return true;
546546
}
547547

548-
bool Menu::ShowAsContextMenu() {
548+
bool Menu::Open() {
549549
POINT pt;
550550
GetCursorPos(&pt);
551-
return ShowAsContextMenu(pt.x, pt.y);
551+
return Open(pt.x, pt.y);
552552
}
553553

554554
bool Menu::Close() {

0 commit comments

Comments
 (0)