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 24/** 25 * Provides cursor positioning, scrolling and text selection functionality in a {@link TextView}. 26 * <p> 27 * The {@link TextView} delegates handling of key events, trackball motions and touches to 28 * the movement method for purposes of content navigation. The framework automatically 29 * selects an appropriate movement method based on the content of the {@link TextView}. 30 * </p><p> 31 * This interface is intended for use by the framework; it should not be implemented 32 * directly by applications. 33 * </p> 34 */ 35public interface MovementMethod { 36 public void initialize(TextView widget, Spannable text); 37 public boolean onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event); 38 public boolean onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event); 39 40 /** 41 * If the key listener wants to other kinds of key events, return true, 42 * otherwise return false and the caller (i.e. the widget host) 43 * will handle the key. 44 */ 45 public boolean onKeyOther(TextView view, Spannable text, KeyEvent event); 46 47 public void onTakeFocus(TextView widget, Spannable text, int direction); 48 public boolean onTrackballEvent(TextView widget, Spannable text, MotionEvent event); 49 public boolean onTouchEvent(TextView widget, Spannable text, MotionEvent event); 50 public boolean onGenericMotionEvent(TextView widget, Spannable text, MotionEvent event); 51 52 /** 53 * Returns true if this movement method allows arbitrary selection 54 * of any text; false if it has no selection (like a movement method 55 * that only scrolls) or a constrained selection (for example 56 * limited to links. The "Select All" menu item is disabled 57 * if arbitrary selection is not allowed. 58 */ 59 public boolean canSelectArbitrarily(); 60} 61