Implement TrayListener interface and macOS event monitoring #17
+336
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a comprehensive TrayListener interface and adds macOS event monitoring capabilities to the system tray functionality.
Overview
The implementation provides a robust event system for handling tray icon interactions (clicks, right-clicks, double-clicks) that integrates seamlessly with the existing EventDispatcher architecture.
Key Components Added
Event Classes
TrayClickedEvent
- Fired when tray icon is left-clickedTrayRightClickedEvent
- Fired when tray icon is right-clickedTrayDoubleClickedEvent
- Fired when tray icon is double-clickedAll events inherit from
TypedEvent
and provideGetTrayId()
method for identifying which tray triggered the event.TrayListener Interface
Enhanced Tray Class
The
Tray
class now supports event handling through callback-based listeners:macOS Implementation
Added comprehensive macOS event monitoring through:
NSEvent
inspectionThe macOS implementation uses the existing NSStatusItem infrastructure and extends it with proper event handling that was previously missing.
Integration
The implementation follows the repository's established patterns:
EventDispatcher
system for type-safe event handlingExample Usage
Testing
Added comprehensive example (
examples/tray_example
) demonstrating the functionality and validating the API works correctly across all event types.This implementation provides the foundation for rich tray icon interactions on macOS while maintaining compatibility with the existing codebase architecture.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.