Add GenericClickHandler that allows right clicks.
This commit is contained in:
parent
a2c2d92cda
commit
7328e27862
1 changed files with 17 additions and 5 deletions
|
|
@ -114,16 +114,16 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LambdaClickHandler : public ClickHandler {
|
class GenericClickHandler : public ClickHandler {
|
||||||
public:
|
public:
|
||||||
LambdaClickHandler(Fn<void()> handler)
|
GenericClickHandler(Fn<void()> handler)
|
||||||
: _handler([handler = std::move(handler)](ClickContext) { handler(); }) {
|
: _handler([handler = std::move(handler)](ClickContext) { handler(); }) {
|
||||||
}
|
}
|
||||||
LambdaClickHandler(Fn<void(ClickContext)> handler)
|
GenericClickHandler(Fn<void(ClickContext)> handler)
|
||||||
: _handler(std::move(handler)) {
|
: _handler(std::move(handler)) {
|
||||||
}
|
}
|
||||||
void onClick(ClickContext context) const override final {
|
void onClick(ClickContext context) const override {
|
||||||
if (context.button == Qt::LeftButton && _handler) {
|
if (_handler) {
|
||||||
_handler(context);
|
_handler(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -133,6 +133,18 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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(
|
void ActivateClickHandler(
|
||||||
not_null<QWidget*> guard,
|
not_null<QWidget*> guard,
|
||||||
ClickHandlerPtr handler,
|
ClickHandlerPtr handler,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue