craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > UI , Look and Feel, Colors, Navigation, font, Locale Post New Topic   Post A Reply
Can I unregister VK_ENTER ? printer friendly version
next newest post | next oldest post
Author Messages
jabba_pl
Private

Gender: Male
Location:
Registered: Dec 2005
Status: Offline
Posts: 6

Click here to see the profile for jabba_pl Send email to jabba_pl Send private message to jabba_pl Find more posts by jabba_pl Edit or delete this message Reply w/Quote
Posted Tuesday, February 14, 2006 @ 04:26:20  

This is not working :

table1.getTable().unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0));
or
table1.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0));

I want to default VK_ENTER action to not move to next record (next line)

is the simple way to do that ??

Best regards,

--------------------

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Tuesday, February 14, 2006 @ 10:15:36  

The action for ENTER is defined in java JTable, not in quicktable. For JTable you can use java InputMap class to override the behaviour.

A detailed discussion about this can be found at
http://forum.java.sun.com/thread.jspa?threadID=578730&messageID=2918148

An implementation to override F2, ENTER, ESCAPE below

Code:

KeyStroke[] keys = new KeyStroke[]{
KeyStroke.getKeyStroke("F2"),
KeyStroke.getKeyStroke("ENTER"),
KeyStroke.getKeyStroke("ESCAPE")});

InputMap im = new FilteringInputMap(dbTable.getTable().getInputMap(WHEN_FOCUSED), keys);
dbTable.getTable().setInputMap(WHEN_FOCUSED, im);

im = new FilteringInputMap(dbTable.getTable().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT), keys);
dbTable.getTable().setInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, im);

And here is the new InputMap class:

import javax.swing.InputMap;
import javax.swing.KeyStroke;

/**
* An input map used by components that extend swing components that bind
* keystrokes to unwanted actions (Such as ESCAPE, ENTER or F2 in a JTable that
* does not do any editing). For the named keystrokes it return null for the
* binding and so Swing will look outside this component for a binding.
*
* @author Reg Whitton
*/

public class FilteringInputMap extends InputMap {

private KeyStroke[] keys;

public FilteringInputMap(InputMap parent, KeyStroke[] keys) {
super();
setParent(parent);
this.keys = keys;
}

public Object get(KeyStroke keyStroke) {
for(int i=0; i<keys.length; i++){
if(keyStroke.equals(keys[i])){
return null;
}
}
return super.get(keyStroke);
}
}

jabba_pl
Private

Gender: Male
Location:
Registered: Dec 2005
Status: Offline
Posts: 6

Click here to see the profile for jabba_pl Send email to jabba_pl Send private message to jabba_pl Find more posts by jabba_pl Edit or delete this message Reply w/Quote
Posted Tuesday, February 14, 2006 @ 13:27:08  

Thanx a lot, now I have everything I need.

--------------------

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios