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:
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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(
|
||||
not_null<QWidget*> guard,
|
||||
ClickHandlerPtr handler,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue