Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sinister Zeta Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sinister Zeta
Sinister Zeta Project
Commits
ded817e8
Commit
ded817e8
authored
4 years ago
by
Dallin Nickel (djn011)
Committed by
NikolaBabic
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Created Binding class which binds a hotkey with an action
parent
6ea8debb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/model/Action.java
+13
-10
13 additions, 10 deletions
src/model/Action.java
src/model/Binding.java
+29
-0
29 additions, 0 deletions
src/model/Binding.java
with
42 additions
and
10 deletions
src/model/Action.java
+
13
−
10
View file @
ded817e8
package
model
;
import
java.awt.*
;
import
java.awt.event.KeyEvent
;
import
javax.swing.JFrame
;
public
class
Action
implements
InputEmulator
{
public
class
Action
extends
Hotkey
implements
InputEmulator
{
/**
* Robot
to
simulate
button
presses
* Robot
which
simulate
s user key
presses
*/
Robot
robot
;
/**
* Constructor to create a new robot to control key presses
* @throws AWTException
* Constructs an immutable hotkey.
* @param keyCode The virtual keycode of the hotkey.
* @param id The unique ID of the hotkey.
* @param modifier The modifier of the hotkey.
*/
public
Action
()
throws
AWTException
{
public
Action
(
int
keyCode
,
int
id
,
Modifier
modifier
)
throws
AWTException
{
super
(
keyCode
,
id
,
modifier
);
this
.
robot
=
new
Robot
();
}
/**
...
...
@@ -26,7 +27,9 @@ public class Action implements InputEmulator{
*/
@Override
public
void
sendKey
(
int
keyCode
,
boolean
release
)
{
robot
.
keyPress
(
keyCode
);
robot
.
keyRelease
(
keyCode
);
if
(
release
)
{
robot
.
keyPress
(
this
.
getKeyCode
());
robot
.
keyRelease
(
this
.
getKeyCode
());
}
}
}
This diff is collapsed.
Click to expand it.
src/model/Binding.java
0 → 100644
+
29
−
0
View file @
ded817e8
package
model
;
public
class
Binding
{
/**
* Hotkey to be bound to an action
*/
Hotkey
hotkey
;
/**
* Action preformed when hotkey is pressed
*/
Action
action
;
/**
* The id of the hotkey and action pairing
*/
int
id
;
/**
* Constructor to bind the hotkey and the action together
* @param hotkey hotkey which is submitted
* @param action the action to be preformed when the hotkey is pressed
*/
public
Binding
(
Hotkey
hotkey
,
Action
action
){
this
.
hotkey
=
hotkey
;
this
.
action
=
action
;
this
.
id
=
hotkey
.
getID
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment