1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of 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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.text.method; 18 19import android.widget.TextView; 20import android.view.KeyEvent; 21import android.view.MotionEvent; 22import android.text.*; 23 24public interface MovementMethod 25{ 26 public void initialize(TextView widget, Spannable text); 27 public boolean onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event); 28 public boolean onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event); 29 30 /** 31 * If the key listener wants to other kinds of key events, return true, 32 * otherwise return false and the caller (i.e. the widget host) 33 * will handle the key. 34 */ 35 public boolean onKeyOther(TextView view, Spannable text, KeyEvent event); 36 37 public void onTakeFocus(TextView widget, Spannable text, int direction); 38 public boolean onTrackballEvent(TextView widget, Spannable text, 39 MotionEvent event); 40 public boolean onTouchEvent(TextView widget, Spannable text, 41 MotionEvent event); 42 43 /** 44 * Returns true if this movement method allows arbitrary selection 45 * of any text; false if it has no selection (like a movement method 46 * that only scrolls) or a constrained selection (for example 47 * limited to links. The "Select All" menu item is disabled 48 * if arbitrary selection is not allowed. 49 */ 50 public boolean canSelectArbitrarily(); 51} 52