Comments (8)
Problem re-created. I'm investigating it now...
Original comment by [email protected]
on 12 Aug 2008 at 6:44
- Changed state: Accepted
from jsyntaxpane.
Problem is that in SyntaxActions, at about line 340 (labeled 7 here):
1 public static void addAction(JTextComponent control, String stroke,
2 TextAction action) {
3 KeyStroke ks = KeyStroke.getKeyStroke(stroke);
4 if (ks == null) {
5 throw new IllegalArgumentException("invalid keystroke: " + stroke);
6 }
7 control.getKeymap().addActionForKeyStroke(ks, action);
8 }
The same keymap is used by all EditorPanes. Probably the default one. Need a
way to
add bindings to a specific keymap just for that pane. I'll research the Keymap
hierarchy classes later when I have a chance.
Could be tricky, but a very good bug catch!
Original comment by [email protected]
on 12 Aug 2008 at 7:05
from jsyntaxpane.
Looked at Swing keymaps, and so far no idea how to resolve this. Most keymap
methods
are static methods of the TextComponent. So how can I add a key binding to
just one
component? Any ideas anybody?
Original comment by [email protected]
on 15 Aug 2008 at 8:15
from jsyntaxpane.
Thanks @javlopez for finding this tricky issue!
Think we should create a custom Keymap and do setKeymap() on JTextComponent.
When we
do a getKeymap(), this custom object will be returned to us. I don't know if we
can
clone() the existing Keymap and set it again:
// init code
Keymap commonKeymap = control.getKeymap();
Keymap customKeymap = (Keymap)((Colonable)commonKeymap).clone();
control.setKeymap(customKeymap);
// Later
control.getKeymap().addActionForKeyStroke(ks, action);
Original comment by subwiz
on 16 Aug 2008 at 7:29
from jsyntaxpane.
I am getting class cast exception when trying to cast to Cloneable! So above
approach
does not hold good!
Original comment by subwiz
on 16 Aug 2008 at 8:06
from jsyntaxpane.
<quote>
JTextComponent defines getKeymap() and setKeymap() methods you can use to query
and
set the current keymap of a text component. There are no public implementations
of
the Keymap interface, so you cannot instantiate one directly. Instead, create
a new
Keymap by calling the static JTextComponent.addKeymap() method. This method
allows
you to specify a name and parent for the new Keymap. Both arguments are
optional,
however, so you may pass in null.
</quote>
From: http://www.unix.com.ua/orelly/java-ent/jfc/ch03_08.htm
And see this for creating private keymap which is used only by our component:
http://books.google.com/books?id=E0HGXKrxcS8C&pg=PA89&lpg=PA89&dq=swing+Keymap+c
ommon+to+all+component&source=web&ots=jeZVgHPlH5&sig=wArw85z8_ZV_q9FZKvCsQt9FHEA
&hl=en&sa=X&oi=book_result&resnum=3&ct=result
So basically, it is:
// init
Keymap jsyntaxpaneKeyMap = JTextComponent.addKeymap(null,
JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
// immdtly after creating TextComponent:
control.setKeymap(jsyntaxpaneKeyMap);
// Now, this should work:
control.getKeymap().addActionForKeyStroke(ks, action);
Original comment by subwiz
on 16 Aug 2008 at 8:22
from jsyntaxpane.
Rev. 30 has a fix. Let me know if it works!
Original comment by subwiz
on 16 Aug 2008 at 8:58
- Changed state: Fixed
from jsyntaxpane.
Another regression issue was fixed in rev.31.
Original comment by subwiz
on 16 Aug 2008 at 9:35
from jsyntaxpane.
Related Issues (20)
- Doesn't play nice with Groovy's SwingBuilder HOT 2
- sql.flex - SQL identifiers can contain #
- PATCH: Allow kit config to specify multiple fonts
- Can't change font in jsyntaxpane HOT 1
- "Find next" bug when no searches have been performed
- Popup menu text not being set
- java.lang.NullPointerException when double click on autocomlete in GroovySyntaxKit HOT 2
- HTML/JavaScript/PHP/CSS Combo-Content-Type
- Do not install the popup menu
- Feature Request - Save Content To Disk
- Unable to access ComboCompletitonAction to create own autocomplites
- LineNumbersRuler font doesn't follow JEditorPane font
- Ctrl-F find enhancement
- NPE when the ruler is installed before the scrollPane
- Question
- SQL display error ("T" = 7) looks like '"T" = 7)
- Some forks/patches
- Cannot properly place text cursor with Japanese characters
- Performance problem for loading large files (>3MB) - and a fix HOT 2
- New, bugfixed, updated version available at GitHub
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsyntaxpane.