Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.scene.input; 027 028import javafx.geometry.Point2D; 029 030/** 031 * InputMethodRequests defines the requests that a text editing node 032 * has to handle in order to work with input methods. The node can 033 * implement this interface itself or use a separate object that 034 * implements it. The object implementing this interface must be 035 * returned from the node's getInputMethodRequests method. 036 * 037 * @since JavaFX 2.0 038 */ 039public interface InputMethodRequests { 040 041 /** 042 * Gets the location of a specified offset in the current composed text, 043 * or of the selection in committed text. This information is, for example, 044 * used to position the candidate window near the composed text, or a 045 * composition window near the location where committed text will be 046 * inserted. 047 * 048 * @param offset the offset within the composed text, if there is 049 * composed text; null otherwise 050 * @return a point representing the screen location of the offset 051 */ 052 Point2D getTextLocation(int offset); 053 054 /** 055 * Gets the offset within the composed text for the specified absolute x 056 * and y coordinates on the screen. This information is used, for example 057 * to handle mouse clicks and the mouse cursor. The offset is relative to 058 * the composed text, so offset 0 indicates the beginning of the composed 059 * text. 060 * 061 * @param x the absolute x coordinate on screen 062 * @param y the absolute y coordinate on screen 063 * @return the offset in the composed text. 064 */ 065 int getLocationOffset(int x, int y); 066 067 /** 068 * Gets the latest committed text from the text editing node and removes 069 * it from the node's text body. This is used for the "Undo Commit" 070 * feature in some input methods, where the committed text reverts to 071 * its previous composed state. The composed text will be sent to the 072 * node using an InputMethodEvent. 073 */ 074 void cancelLatestCommittedText(); 075 076 /** 077 * Gets the currently selected text from the text editing node. This may 078 * be used for a variety of purposes. One of them is the "Reconvert" 079 * feature in some input methods. In this case, the input method will 080 * typically send an input method event to replace the selected text 081 * with composed text. Depending on the input method's capabilities, 082 * this may be the original composed text for the selected text, the 083 * latest composed text entered anywhere in the text, or a version of 084 * the text that's converted back from the selected text. 085 * 086 * @return the latest committed text, or null when the "Undo Commit" 087 * feature is not supported 088 */ 089 String getSelectedText(); 090}