BInputServerMethod¶
BInputServerMethod
is a base class for input methods; these
are instances of BInputServerMethod
that act as an interface
between the user and languages using character sets that can’t be easily
represented on standard keyboards, such as the Japanese input method that
comes with BeOS.
Input methods generally handle B_KEY_DOWN
messages in
their Filter()
function (see
BInputServerFilter
), keeping some sort of state around to
translate these standard keyboard messages into new
B_KEY_DOWN
messages representing another character set.
An input method can handle any input event, they’re not limited to keyboard
events.
Warning
Writing an input method is an involved process, even though the BInputServerMethod protocol is relatively simple. If you’re working on an input method, please feel free to contact Be Developer Technical Support (devsupport@be.com) for additional information.
Input Method Events¶
Input methods insert B_INPUT_METHOD_EVENT
messages (using
their EnqueueMessage()
function) into the
Input Server’s event stream. These messages let BView
subclasses work together with your input method to create a seamless
experience for the user.
Each B_INPUT_METHOD_EVENT
message contains a
be:opcode field (an int32 value) indicating the kind of
event:
Constant |
Description |
---|---|
|
Indicates that a new input transaction has begun. Add a
|
|
Indicates that the transaction is over. |
In between the B_INPUT_METHOD_STARTED
and
B_INPUT_METHOD_STOPPED
messages, you’ll send
B_INPUT_METHOD_CHANGED
and
B_INPUT_METHOD_LOCATION_REQUEST
messages as the
transaction proceeds.
B_INPUT_METHOD_CHANGED
does most of the work in an input
transaction; add the following important fields:
Entry |
Type |
Description |
---|---|---|
be:string |
|
The text the user is currently entering; the receiver will display it at
the current insertion point. |
be:selection |
|
A pair of B_INT32_TYPE offsets into the be:string if part of
be:string is current selected. |
be:clause_start |
|
Zero or more offsets into the be:string for handling languages
(such as Japanese) that separate a sentence or phrase into numerous
clauses. An equal number of be:clause_start and
be:clause_end pairs delimit these clauses; |
be:clause_end |
|
Zero or more offsets into be:string; there must be as many be:clause_end entries as there are be:clause_start. |
be:confirmed |
|
True when the user has entered and “confirmed” the current string and
wishes to end the transaction. |
B_INPUT_METHOD_LOCATION_REQUEST
is the input method’s way
of asking for the on-screen location of each character in
be:string. This information can be used by the input method to
pop up additional windows giving the user an opportunity to select
characters from a list or anything else that makes sense. When you send a
B_INPUT_METHOD_LOCATION_REQUEST
, the receiver will reply
to the be:reply_to messenger (that you sent in your
B_INPUT_METHOD_STARTED
message) with a
B_INPUT_METHOD_EVENT
message, filling in the following
fields:
Entry |
Type |
Description |
---|---|---|
be:opcode |
|
Set to |
be:location_reply |
|
The co-ordinates of each character (there should be one be:location_reply for every character in be:string) relative to the display (not your view or your window). |
be:height_reply |
|
The height of each character in be:string. |
Creating¶
To create a new input method, you must:
Create a subclass of
BInputServerMethod
Implement the instantiate_input_method() C function to create an instance of your
BInputServerMethod
subclassCompile the class and function as an add-on
Install the add-on in one of the input method directories
At boot time (or whenever the Input Server is restarted; see “Dynamic Loading”), the Input Server loads the add-ons it finds in the input method directories. For each add-on it finds, the Server invokes instantiate_input_method() to get a pointer to the add-on’s BInputServerMethod object. After constructing the object, the Server calls InitCheck() to give the add-on a chance to bail out if the constructor failed.
Installing an Input Method¶
The input server looks for input methods in the “input_server/methods”
subdirectories of B_BEOS_ADDONS_DIRECTORY
,
B_COMMON_ADDONS_DIRECTORY
, and
B_USER_ADDONS_DIRECTORY
.
You can install your input devices in the latter two directories—i.e. those under
B_COMMON_ADDONS_DIRECTORY
, andB_USER_ADDONS_DIRECTORY
.The
B_BEOS_ADDONS_DIRECTORY
is reserved for add-ons that are supplied by the BeOS.