Skip to content

Commit

Permalink
Add GenericClickHandler that allows right clicks.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Feb 2, 2024
1 parent a2c2d92 commit 7328e27
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions ui/click_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ class LeftButtonClickHandler : public ClickHandler {

};

class LambdaClickHandler : public ClickHandler {
class GenericClickHandler : public ClickHandler {
public:
LambdaClickHandler(Fn<void()> handler)
GenericClickHandler(Fn<void()> handler)
: _handler([handler = std::move(handler)](ClickContext) { handler(); }) {
}
LambdaClickHandler(Fn<void(ClickContext)> handler)
GenericClickHandler(Fn<void(ClickContext)> handler)
: _handler(std::move(handler)) {
}
void onClick(ClickContext context) const override final {
if (context.button == Qt::LeftButton && _handler) {
void onClick(ClickContext context) const override {
if (_handler) {
_handler(context);
}
}
Expand All @@ -133,6 +133,18 @@ class LambdaClickHandler : public ClickHandler {

};

class LambdaClickHandler : public GenericClickHandler {
public:
using GenericClickHandler::GenericClickHandler;

void onClick(ClickContext context) const override final {
if (context.button == Qt::LeftButton) {
GenericClickHandler::onClick(std::move(context));
}
}

};

void ActivateClickHandler(
not_null<QWidget*> guard,
ClickHandlerPtr handler,
Expand Down

0 comments on commit 7328e27

Please sign in to comment.