}
MIM.Key.prototype.toString = function () { return this.key; };
+
+ MIM.Key.FocusIn = new MIM.Key (new Xex.StrTerm ('input-focus-in'));
+ MIM.Key.FocusOut = new MIM.Key (new Xex.StrTerm ('input-focus-out'));
+ MIM.Key.FocusMove = new MIM.Key (new Xex.StrTerm ('input-focus-move'));
}) ();
(function () {
var ic = domain.context;
var n = args.length == 0 ? -2 : args[0].val;
if (n < 0)
- ic.keys.val.splice (ic.keys.length + n, -n);
+ ic.keys.val.splice (ic.keys.val.length + n, -n);
else
- ic.keys.val.splice (n, ic.keys.length);
+ ic.keys.val.splice (n, ic.keys.val.length);
ic.reset ();
return Xex.nil;
}
alert ('inclusion fail');
continue;
}
- for (var mapname in im.map_list)
- this.map_list[mapname] = im.map_list[mapname];
+ for (var mname in im.map_list)
+ {
+ this.map_list[mname] = im.map_list[mname];
+ Xex.Log ('include map ' + mname);
+ }
}
else
{
this.domain.map_list = this.map_list;
for (node = node.firstElement (); node; node = node.nextElement ())
{
- if (node.nodeName == 'state')
+ if (node.nodeName == 'xi:include')
+ {
+ var im = include (node);
+ if (! im)
+ alert ('inclusion fail');
+ for (var sname in im.state_list)
+ {
+ state = im.state_list[sname];
+ if (! this.initial_state)
+ this.initial_state = state;
+ this.state_list[sname] = state;
+ Xex.Log ('include state ' + sname);
+ }
+ }
+ else if (node.nodeName == 'state')
{
var state = Xex.Term.Parse (this.domain, node);
if (! state.title)
proto = {
reset: function ()
{
- Xex.Log ('reseting ' + this.im.lang);
+ Xex.Log ('reseting ' + this.im.lang + '-' + this.im.name);
this.cursor_pos = 0;
this.candidate_show = false;
this.prev_state = null;
this.state_var_values = {};
this.state_pos = 0;
this.key_head = 0;
- this.keys.val.length = 0;
this.key_unhandled = false;
this.unhandled_key = null;
this.changed = MIM.ChangedStatus.None;
}
};
+MIM.ignore_focus = false;
+
MIM.update = function (target, ic)
{
var text = target.value;
MIM.set_caret (target, ic);
};
-MIM.reset_ic = function (event)
+MIM.focus_in = function (event)
+{
+ var target = event.target;
+ var ic = target.mim_ic;
+ if (ic)
+ {
+ if (target.mim_ignore_focus_in)
+ {
+ // Ignore this event which happened in setSelectionRange ().
+ target.mim_ignore_focus_in = false;
+ event.preventDefault ();
+ }
+ else
+ {
+ try {
+ ic.Filter (MIM.Key.FocusIn);
+ MIM.update (target, ic);
+ // Ignore further focus-in caused by setSelectionRange ().
+ target.mim_ignore_focus_in = true;
+ }
+ catch (e) { Xex.Log ('Error:' + e); throw (e); }
+ }
+ }
+}
+
+MIM.focus_out = function (event)
{
- if (event.target.mim_ic)
+ var target = event.target;
+ var ic = target.mim_ic;
+ if (ic)
{
- var target = event.target;
- var ic = target.mim_ic;
- if (ic.preedit.length > 0)
- event.target.setSelectionRange (ic.range[1], ic.range[1]);
- ic.reset ();
+ if (target.mim_ignore_focus_out)
+ {
+ // Ignore this event which caused by setSelectionRange ().
+ target.mim_ignore_focus_out = false;
+ event.preventDefault ();
+ }
+ else
+ {
+ try {
+ if (! MIM.get_range (target, ic))
+ ic.reset ();
+ ic.Filter (MIM.Key.FocusOut);
+ MIM.update (target, ic);
+ // Ignore further focus-out caused by setSelectionRange ().
+ target.mim_ignore_focus_out = true;
+ }
+ catch (e) { Xex.Log ('Error:' + e); throw (e); }
+ }
}
};
return;
if (! (target.type == "text" || target.type == "textarea"))
return;
+ document.akey = event;
var ic = target.mim_ic;
if (! ic || ic.im != MIM.current)
if (ic.im.load_status != MIM.LoadStatus.Loaded)
return;
target.mim_ic = ic;
- MIM.add_event_listener (target, 'blur', MIM.reset_ic);
+ MIM.add_event_listener (target, 'focus', MIM.focus_in);
+ MIM.add_event_listener (target, 'blur', MIM.focus_out);
MIM.get_range (target, ic)
}
else
try {
var result = ic.Filter (ic.key);
} catch (e) {
- Xex.Log ('Error;' + e);
+ Xex.Log ('Error' + e);
throw (e);
}
MIM.update (target, ic);