-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event handling capability to all the widgets
- Loading branch information
Showing
50 changed files
with
448 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include "_cgo_export.h" | ||
|
||
|
||
class WidgetWithEventHandler { | ||
public: | ||
virtual void set_event_handler(int handlerId) = 0; | ||
}; | ||
|
||
template<class BaseWidget> | ||
class EventHandler : public BaseWidget, public WidgetWithEventHandler { | ||
public: | ||
template<class... Arg> | ||
EventHandler(Arg... args) | ||
: BaseWidget(args...) {} | ||
|
||
int handle(int event) final { | ||
if (m_eventHandlerId >= 0) { | ||
const int ret = _go_eventHandler(m_eventHandlerId, event); | ||
if (ret != 0) { | ||
return ret; | ||
} | ||
} | ||
return BaseWidget::handle(event); | ||
} | ||
|
||
void set_event_handler(int handlerId) final { | ||
m_eventHandlerId = handlerId; | ||
} | ||
|
||
protected: | ||
int m_eventHandlerId = -1; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.