KeyboardActionListener.java revision e59491460b0411bed430a5ca6eca0c56c5bf18d9
1/* 2 * Copyright (C) 2010 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17package com.android.inputmethod.keyboard; 18 19public interface KeyboardActionListener { 20 21 /** 22 * Called when the user presses a key. This is sent before the {@link #onCodeInput} is called. 23 * For keys that repeat, this is only called once. 24 * 25 * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key, 26 * the value will be zero. 27 * @param withSliding true if pressing has occurred because the user slid finger from other key 28 * to this key without releasing the finger. 29 */ 30 public void onPress(int primaryCode, boolean withSliding); 31 32 /** 33 * Called when the user releases a key. This is sent after the {@link #onCodeInput} is called. 34 * For keys that repeat, this is only called once. 35 * 36 * @param primaryCode the code of the key that was released 37 * @param withSliding true if releasing has occurred because the user slid finger from the key 38 * to other key without releasing the finger. 39 */ 40 public void onRelease(int primaryCode, boolean withSliding); 41 42 /** 43 * Send a key code to the listener. 44 * 45 * @param primaryCode this is the code of the key that was pressed 46 * @param keyCodes the codes for all the possible alternative keys with the primary code being 47 * the first. If the primary key code is a single character such as an alphabet or 48 * number or symbol, the alternatives will include other characters that may be on 49 * the same key or adjacent keys. These codes are useful to correct for accidental 50 * presses of a key adjacent to the intended key. 51 * @param x x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by 52 * {@link PointerTracker#onTouchEvent} or so, the value should be 53 * {@link #NOT_A_TOUCH_COORDINATE}. 54 * @param y y-coordinate pixel of touched event. If {@link #onCodeInput} is not called by 55 * {@link PointerTracker#onTouchEvent} or so, the value should be 56 * {@link #NOT_A_TOUCH_COORDINATE}. 57 */ 58 public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y); 59 60 public static final int NOT_A_TOUCH_COORDINATE = -1; 61 62 /** 63 * Sends a sequence of characters to the listener. 64 * 65 * @param text the sequence of characters to be displayed. 66 */ 67 public void onTextInput(CharSequence text); 68 69 /** 70 * Called when user released a finger outside any key. 71 */ 72 public void onCancelInput(); 73 74 /** 75 * Called when the user quickly moves the finger from up to down. 76 */ 77 public void onSwipeDown(); 78} 79