Created
August 2, 2025 03:45
-
-
Save SavSanta/e3b9d9cf5ee582fbfb02b1051e9a623f to your computer and use it in GitHub Desktop.
WorkingAddKeyListenerInterfaceInAggressorScript
This file contains hidden or 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
| debug(7); | |
| global('$frame $button $clicked'); | |
| import javax.swing.*; | |
| import java.awt.*; | |
| import java.awt.event.*; | |
| global('$dialog $label $label2'); | |
| #$dialog = dialog("Shortcut", 200, 200); | |
| $dialog = [new JDialog: $frame, 200]; | |
| $label = [new JTextField: "Type the desired key:"]; | |
| #$label2 = [new JLabel: "The New Second Label:"]; | |
| [$dialog add: $label]; | |
| #[$dialog add: $label2]; | |
| [$dialog pack]; | |
| [$label setFocusTraversalKeys: [KeyboardFocusManager FORWARD_TRAVERSAL_KEYS], [new HashSet]]; | |
| [$label setFocusTraversalKeys: [KeyboardFocusManager BACKWARD_TRAVERSAL_KEYS], [new HashSet]]; | |
| [$label setFocusTraversalKeys: [KeyboardFocusManager UP_CYCLE_TRAVERSAL_KEYS], [new HashSet]]; | |
| [$label addKeyListener: lambda({ | |
| println("Arg \$0 to lambda -> $0\nArg \$1 to lambda -> $1 "); | |
| println("Will this print x - $x "); | |
| if ($0 eq "keyReleased") { | |
| [$label setText: strrep([KeyStroke getKeyStrokeForEvent: $1], 'released', 'pressed')]; | |
| #[$label setText: "Booyah"]; | |
| #[$model fireListeners]; | |
| #[$dialog setVisible: 0]; | |
| } | |
| }, $x => "opiate" ) ]; | |
| [$dialog setVisible: 1]; | |
| #[$dialog show]; | |
| #[$label requestFocus]; |
Author
Author
My lambda in use ```
[$txtfld addKeyListener: lambda({
$ev = $1;
$code = [$ev getKeyCode];
$STOPCODE = @(10, 27, 37, 38, 39, 40);
# America
if ($code in $STOPCODE) {
$ACTIVECSPC = $null;
$BINPCONTS = "";
$COMPIDX = 0;
}
})];
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shit should work now for other interfaces too. This demos how abstract classes can be overiden without using the Proxy/JavaAdapter()/JProxy()/XProxy.
Additionally this shows @Override/Implementation in modern Sleep/Aggressor Script.
unsure if the implementation would work with KeyAdapter however but this snippet was adapted from the less than great to parse and absolutely poorly documented code digging in rsmudge's anciet repo for Armitage (which used Cortana (ancient ass Sleep before Aggressor Script)). Reference https://github.com/rsmudge/armitage/blob/c8ca6c00b5584444ef3c3a8e32341f43974567bd/scripts/preferences.sl#L349
There may be a method to do this using newInstance (esp if possible to implement with Abstract Classes) as that via documentation seemed to imply it but after spending 3 hours futzing with the horribly complex docs, I ended up managing to do it this way ...so this is fine