Capture 'Enter' key event
Hi,
Is there any way we can capture the event when a user presses the enter key inside a text field?
Hi andrewquay
you can capture the enter key by adding the following code in the textfield's change event.
if(xfa.event.change == "\u000a")
xfa.host.messageBox("enter key is pressed");
mail: [email protected]
Similar Messages
-
Capturing Enter key event from text box
In my application, there are a number of text boxes. I want to create a feature where an enter key even is seen and specific function executed depending on which text box was in focus when the enter key was pressed. Currently I am able to capture an enter key event on the whole page. How do I do that specifically for a text box?
This application is done in HTML, javascript and Adobe AIR.
Thanks
Binu
www.verseview.infoHi
That's true that Flex4.5 SDK under Flash builder Burito doesn't listen Enter key in Text Area for KeyUp or KeyDown event.
Here I found a work around you can use.
Add an eventlistener to the component in actionscript and set the useCapture=true next to eventlistener function. Now you can listen enter key for KeyUp or KeyDown Event
Hope this helps
Rush-me -
Flex4.5 SDK under Flash builder Burito doesnt dispatch Enter key event in Text Area anymore
Flex 4.5 under Flash builder Burito doesnt dispatch 'Enter' key event in Text Area anymore, in prev version 4.1 it was working properly, this stopped working after migration to Burito + Flex SDK 4.5?
What that suppose to be?Hi
That's true that Flex4.5 SDK under Flash builder Burito doesn't listen Enter key in Text Area for KeyUp or KeyDown event.
Here I found a work around you can use.
Add an eventlistener to the component in actionscript and set the useCapture=true next to eventlistener function. Now you can listen enter key for KeyUp or KeyDown Event
Hope this helps
Rush-me -
Hi Experts,
Am using an editable alv. I want to perform some actions when Enter key is pressed.
I did this in DOMODIFY. But this makes the scroll bar in initial position. Kindly help me on this.
Regards,
Vijayakumar.Hi vijayakumar,
You can refer this link for info about ENTER key event trigger. Could you please post what you want to perform when Enter key is pressed.
Link: [http://wiki.sdn.sap.com/wiki/display/ABAP/InteractiveEditableOOALVgridwithdynamicitab,FCATandENTERkeyeventtrigger]
Regards,
Anand G -
Enter Key Event in Editable ALV Grid
Hi all,
I am trying to create and editable ALV grid using the REUSE ALV FM.
On the grid after changing a value, if I press enter key the pai is not triggered. I have tried the various example programs (BCALV*) but could not find anything relevant.
Basically I need similar functionality to normal module pool programming as in validations on screen done when enter key is pressed after screen entry.
Is it possible to capture the Enter keypress on the ALV grid?Hello Preet
I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
I assume that the logic will be similar using ALV function modules.
Regards
Uwe -
Handling 'enter key' event in alv using classes
Hello all,
i have a scenario where i have a grid from which i have to select a row and press 'enter' key, then the row would be added to grid on top of it. we have developed this grids using control and classes.
please any one tell me how would i get the enter key code.
Thanks,
krishnam raju NHI Raju
just go through these
check the sample program.
<b>BALV_POPUP_TO_SELECT
ENTER is nothing but selecting the record.
</b>
Re: ALV 'ENTER' key
and go through this code
constants :
C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'F_SET_PF_STATUS'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
I_CALLBACK_USER_COMMAND = P_USER_COMMAND IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING = IT_EXTAB[]
IT_SORT = IT_SORT[]
TABLES
T_OUTTAB = P_ZBCAR50
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2.
*& Form F_SET_PF_STATUS
Set PF_STATUS STANDARD modifying the standard toolbar
by excluding some buttons
-->P_IT_EXTAB -- TABLE OF EXCLUDING FUNCTIONS
FORM F_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
CLEAR : WA_EXTAB,
IT_EXTAB.
*--Set the Modified PF status for the ALV.
SET PF-STATUS 'STATUS_01' EXCLUDING RT_EXTAB.
ENDFORM. " SET_PF_STATUS
3.
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_ANSWER TYPE C.
RS_SELFIELD-REFRESH = C_X.
IF R_UCOMM = 'ENTR'.
Do your processing here.
ENDIF
and go through these links
<b>how to identify pressing ENTER on ALV
How to capture the event in ALV grid display?
Re: ALV-Grid: No reaction to Enter-Button
</b>
IF IT HELPS REWARD WITH POINTS
Regards Rk
Message was edited by:
Rk Pasupuleti -
Hi
Is there a way where we can capture the Enter Key press of the Keyboard and call an event on the Enter Key Press??
For fields such as input field there is onEnter field where an event can be called, but we have a requirement where in we need to call an event on click of enter key, irrespective of where the focus on the page is on.
Any inpus on this will be helpful.
Thanks & Regards,
Gayathri ShanbhagHi Gayathri,
See if the following link helps:
https://cw.sdn.sap.com/cw/docs/DOC-107045
Regards,
Himanshu -
Capture enter key press in h:inputtext
hi,
i have a h:inputText component in my jsf page. i need to capture the enter key pressed for this component. how can this be done.
thanks in advance.You can use Javascript for this. In the onkeypress event, check if the keycode is 13 (the enter key) and handle accordingly.
onkeypress="if (event.keyCode == 13) alert('Enter pressed!');" -
Handling Enter key event in JTable
Hi...
This is particularly for the user "VIRAVAN"...
I have followed your method ,and got results too.. but the
processKeyBinding(.. method is called 4 times,same problem addressed by you before, but I didn't understood it...
Please help me...
Here is my code...
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,int condition, boolean pressed)
System.out.println("Wait");
if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0))
int selRow = getSelectedRow();
int rowCount = getRowCount();
int selCol = getSelectedColumn();
String val =(String)getValueAt(selRow,selCol);
boolean b= getCellEditor(selRow,selCol).stopCellEditing();
System.out.println(b);
System.out.println(rowCount-1 + " "+ selRow + " " + getSelectedColumn());
if((!val.equals("")) && selRow==rowCount-1)
System.out.println(rowCount-1 + " "+ getSelectedRow()+ " " + getSelectedColumn());
blank1 = new String[columns];
for(int p=0;p<columns;p++)
blank1[p]="";
Diary.this.datarows.addElement(blank1);
// dataModel.fireTableStructureChanged();
//dataModel.fireTableDataChanged();
Diary.this.dataModel.fireTableChanged(null);
else if(ks ==KeyStroke.getKeyStroke(KeyEvent.VK_1,0))
System.out.println("One One One One ");
return super.processKeyBinding(ks,e,condition,pressed);It's been a while since I looked at the code, but essentially there are three key event types:
1) key pressed,
2) key typed,
3) key released.
So I would expect the processKeyBind to see all three of them. However, ks==KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0) is true only when a key typed event is detected (the other types can be ignored by passing it up the food chain where they will eventually be consumed). Now...., if I understand you correctly, you want to terminate edit on the present of Enter key, right? Here is how I'd suggest you do:
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (isEditing()) {
Component editorComponent=getEditorComponent();
editorComponent.stopCellEditing();
return true;
return super.processKeyBinding(ks,e,condition,pressed);
}Ok.... now, it appears that you want to do something else also... i.e., add a new row to the table if the editing row is the last row and the editing column is the last column of the last row. You can't do that in the same thread (i.e., you must wait until the update in the current thread is completed). So, what you must do is use the SwingUtilities.InvokeLater, like this:
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (isEditing()) {
Component editorComponent=getEditorComponent();
editorComponent.stopCellEditing();
if (getEditingRow()+1==getRowCount() && getEditingColumn()+1==getColumnCount()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// put the code for adding new row here
return true;
return super.processKeyBinding(ks,e,condition,pressed);
}OK?
;o)
V.V.
PS: posted code is untest but should work! -
Capture ENTER key on numeric keypad
I have several chemistry tutorials where users type something and then have it evaluated by pressing the ENTER key. This works fine for the ENTER key on the main part of the keyboard, but does not work for the ENTER key for the numeric keypad on keyboards with the two ENTER keys. How do I capture the ENTER key on the numeric keypad? In other words, how do I do the equivalent of the following for that key?
if the key = RETURN then
ThanksTry checking:
if _key.keyCode = 36 then ... -
Capture desktop key event to control my screen capture app
I want to write a screen capture program to capture screen when I am playing fullscreen game or other desktop window application. But the java screen capture program can only receive key or mouse event when it is focused. So how do I capture key event when I am focusing other app or fullscreen app?
Do I have to use JNI and call some OS specific API. My target OS is WinXP. Help or suggestions are appreciated!!Hi All,
I was wondering if there is a way to capture the top-most
window or dialog box. This is something that will
generally be running outside of the JVM....We,
as programmers, need a Rectangle instance that describes the area
of interest to be captured (i.e., location and size).
Thus, a routine that interfaces to the Native windowing system (Toolkit?)
might look something like:
Rectangle rect = tk.getRectangleForTopMostComponent();
Does anything like this exist?
Thanks!
- DocJava -
KeyListener does not capture Arrow key Events in textField
Love................
I added a key listener to TextField it does not detect
Arrow Keys events in keyTyped, KeyPressed,KeyReleased methods
why?????
I want to shift focus from a textfield to other component
on capturing Arrow key Pressed HowHere is a Java demo where it works since it is not a printable character you must get the keyCode:
http://java.sun.com/docs/books/tutorial/uiswing/events/example-swing/index.html#KeyEventDemo
public class KeyEventDemo ... implements KeyListener ... {
...//where initialization occurs:
typingArea = new JTextField(20);
typingArea.addKeyListener(this);
/** Handle the key typed event from the text field. */
public void keyTyped(KeyEvent e) {
displayInfo(e, "KEY TYPED: ");
/** Handle the key pressed event from the text field. */
public void keyPressed(KeyEvent e) {
displayInfo(e, "KEY PRESSED: ");
/** Handle the key released event from the text field. */
public void keyReleased(KeyEvent e) {
displayInfo(e, "KEY RELEASED: ");
protected void displayInfo(KeyEvent e, String s){
char c = e.getKeyChar();
int keyCode = e.getKeyCode();
int modifiers = e.getModifiers();
tmpString = KeyEvent.getKeyModifiersText(modifiers);
...//display information about the KeyEvent...
} -
Hi all,
I m getting an input from the user in an Inputfield. I also have a table with two columns.
The textfield is used to perform wildcard search (filter) for the table. That is, if i give a character like 'A', then the records which start with the character 'A' must be shown in the table when i press teh ENTER key..
I have got this outptu when i click a button. But i want to get the same output, when i give 'A' and press ENTER key..
How to acheive the same in WD4A?
Regards,
Shanthihi Shanthi,
for the corresponding Enter key , make a action say act in the EventPropery of the element.
in the Onactionact,method in the Methods tab , write the same piece of code , which u r writting in the Button
u wud be able to do it nw
regards,
amit -
Problem capturing "Enter Key" within 2 paragraph in JSP
I create a textarea for customer to enter their data. Something the data contain 2 paragraph with Enter Key involve. Then, i store the data into my database. Once i re-display the data back to customer, the data never show in 2 paragraph ?
who know.... pls pls help..... in JSP how am i going to do, so that the data disply in 2 paragraph.Are you displaying the data again in TextArea? If not then you need to take care of '\r\n'. Split the data for '\r\n' and display the data in two paragraphs.
String wholeData="Your_Paragraph1\r\nYour_Paragraph2";
StringTokenizer st = new StringTokenizer(wholeData,"\r\n");
while(st.hasMoreTokens()) our.print(st.nextToken()+"<br>");Hope this helps.
Sudha -
In ALV display model ,how to accept the ENTER key event?
Dear All,
I have used ALV by GRID DISPLAY model ,not class model.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'T_ITAB'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = t_itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
For example :
IN ALV DISPLAY, there are two fields, one is MATNR, the other is MAKTX.
When user input the material value in MATNR field and press ENTER, then ALV can run my code to select the MAKTX into MAKTX field and display it synchronization.
Now I have realized update edit in ALV,but I found only I double click ALV row, then the MAKTX can update.
Please give me help,
Thanks
SunThis is the document written by me on Interactive ALV.. hope this maybe helpful for u..
When an Interactive Report is needed in Classical Display, we go for AT LINE-SELECTION. But when the same is needed in ALV Display, this method won't work. Instead, we need to use other way which is explained below:
We use REUSE_ALV_GRID_DISPLAY for ALV Display. Now, normally we call that FM in the following way:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'PROGRAM_NAME'
it_fieldcat = tb_fieldcat
TABLES
t_outtab = tb_output.
When it is needed to get an Interactive ALV, call the same FM in the following manner:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST75599_1'
it_fieldcat = tb_fieldcat
i_callback_user_command = 'USER_COMMAND'
TABLES
t_outtab = tb_output.
Now, in the report, create a subroutine with the name USER_COMMAND as follows:
FORM user_command USING p_ucomm LIKE sy-ucomm
p_selfield TYPE slis_selfield.
CASE p_ucomm.
WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
Based on the requirement, write the logic *
ENDCASE.
ENDFORM.
No need to call the subroutine as PERFORM user_command. This will be takane care by REUSE_ALV_GRID_DISPLAY. We need to just write the subroutine in the report. That suffices.
Some more useful points for Interactive ALV:
1. If Hotspot is needed, then that should be done by declaring hotspot (one field in slis_t_fieldcat_alv) as 'X' in tb_fieldcat which is of type slis_t_fieldcat_alv. When hotspot is active, single click will be enough or else you should double click on the output data.
2. In Classical Display, when it is needed to read the record on which we double clicked, we do that in following way:
AT LINE-SELECTION.
GET CURSOR LINE wf_line. " wf_line gives the line number on which it has been clicked
READ LINE wf_line OF CURRENT PAGE.
But this won't work for ALV. Instead, the following logic can be used:
FORM user_command USING p_ucomm LIKE sy-ucomm
p_selfield TYPE slis_selfield.
CASE p_ucomm.
WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
READ TABLE tb_output INTO wa_output INDEX p_selfield-tabindex.
IF sy-subrc EQ 0.
Based on the requirement, write the logic *
ENDIF.
ENDCASE.
ENDFORM.
Maybe you are looking for
-
Macbook pro Mini displayport to VGA/HDMI needs restart to work
I am having a strange problem. I have an original Apple mini DisplayPort to VGA adapter and one non-apple mini-displayport to HDMI adapter. When I connect external monitor through either one of those it doesn't work unless i restart my computer. I tr
-
Please Help! My MB pro 2010 quit and auto restart when I upgrade my MB Pro with a SSD
Hi all! Please let me know what's happen with my Mac & help me to solve this problem pls? Since my Mac is on normall working but a little bit slow. So that's why I update it to SSD. But from that day, when I'm working, it suddenly quit & auto restart
-
Saving a PDF creates two files - one I named and one with a gibberish name
I'm hoping someone can help me. I got a new HP laptop (Windows 7) and downloaded Acrobat Standard 9 from the Adobe website when I couldn't find my install disc. When I save a PDF, it saves correctly. However, a second file is created with a gibber
-
Wildcards in Find/Change..
OK, In a references list in a book where it's numbered.. basic stuff..I need to find all instances of (return+## (could be a single or double or TRIPLE digit number)+. (period) and a SPACE and replace with same thing but that space turns into a TAB..
-
Unknown error occured (-200)... Help!!!
Every time I try to open iTunes, this is the message that pops up. Does any one know what to do. I've tried reinstalling and restoring my computer, but I can't seem to get anything to work. Ideas? please. Thank you!