-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for triggering mouse up and down events independently
- Loading branch information
Showing
7 changed files
with
213 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Foundation | ||
|
||
public class MouseDownCommand: MouseClickCommand { | ||
public override class var commandType: CommandType { return .mouseDown } | ||
|
||
private static let _expression = try! NSRegularExpression(pattern: "\\<md:([a-z]+)(:([a-z,]+))?\\>") | ||
public override class var expression: NSRegularExpression { return _expression } | ||
|
||
override init() { | ||
super.init() | ||
} | ||
|
||
public init(button: String?, modifiers: [String]) { | ||
super.init() | ||
|
||
self.button = button | ||
self.modifiers = modifiers | ||
} | ||
|
||
required public init(arguments: [String?]) { | ||
super.init() | ||
|
||
self.button = arguments[1]! | ||
self.modifiers = arguments[3]?.components(separatedBy: ",").filter({ !$0.isEmpty }) ?? [] | ||
} | ||
|
||
public override func execute() throws { | ||
try! mouseController!.down( | ||
nil, | ||
button: getMouseButton(button: button!), | ||
flags: try! KeyPresser.getModifierFlags(modifiers) | ||
) | ||
} | ||
} |
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,34 @@ | ||
import Foundation | ||
|
||
public class MouseUpCommand: MouseClickCommand { | ||
public override class var commandType: CommandType { return .mouseUp } | ||
|
||
private static let _expression = try! NSRegularExpression(pattern: "\\<mu:([a-z]+)(:([a-z,]+))?\\>") | ||
public override class var expression: NSRegularExpression { return _expression } | ||
|
||
override init() { | ||
super.init() | ||
} | ||
|
||
public init(button: String?, modifiers: [String]) { | ||
super.init() | ||
|
||
self.button = button | ||
self.modifiers = modifiers | ||
} | ||
|
||
required public init(arguments: [String?]) { | ||
super.init() | ||
|
||
self.button = arguments[1]! | ||
self.modifiers = arguments[3]?.components(separatedBy: ",").filter({ !$0.isEmpty }) ?? [] | ||
} | ||
|
||
public override func execute() throws { | ||
try! mouseController!.up( | ||
nil, | ||
button: getMouseButton(button: button!), | ||
flags: try! KeyPresser.getModifierFlags(modifiers) | ||
) | ||
} | ||
} |
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