[immodule-qt] I have implemented QInputMethodEvent Property for the discussion
Lars Knoll
lars at trolltech.com
Fri Jan 7 12:03:26 EET 2005
On Monday 03 January 2005 14:27, Daisuke Kameda wrote:
> Lars Knoll <lars at trolltech.com> wrote:
> > You have added a class QInputMethodStrAttr. Do you want to control all
> > attributes of the preedit string through this class? Do you also want to
> > include the preedit selection here and remove the cpos and selLen members
> > from QInputMethodEvent?
>
> Advanced input method requires the very complicated edit function of
> preedit. Therefor, the toolkit should not have assumption about meaning of
> preedit segment's attribute. Instead, it is important that it can display
> as specified.
>
> As mentioned above, I think that is better to abolish the selection itself
> and enable specifying background color and underline's color.
>
> > I can come up with a proposal for a better QInputMethodEvent that
> > includes support for editing of surrounding text and independent commit
> > actions once I know this.
>
> It is good news. I am looking forward to looking the modification.
Below is the structure of the QInputMethodEvent I could imagine after the
discussions we had:
class Q_GUI_EXPORT QInputMethodEvent : public QInputEvent
{
public:
QInputMethodEvent(const QString &preedit);
enum AttributeType {
UnderLineColor,
BackgroundColor,
CursorPosition,
ReplaceString,
Language,
RubyText
};
struct Attribute {
AttributeType type;
QVariant value;
int start;
int length;
};
void setAttribute(const Attribute &value);
QVariant attribute(AttributeType a) const;
QList<Attribute> attributes() const;
private:
QList<Attribute> attributes;
QString preedit;
};
I've added a few attributes to your original proposal, since I think they
might be needed. Here's an explanation of the different attributes:
UnderLineColor:
The underline color for the part of the preedit string specified by start and
length. value contains a QVariant of type QColor specifying the underline
color.
BackgroundColor:
Same as underline color, but specifies the background color for a part of the
preedit string.
CursorPosition:
The current cursor position inside the preedit string. Needed, so the widget
can return the correct position for the microFocusHint when you have a long
preedit string. The variant has no value here, and start specified the cursor
position.
ReplaceString:
Not actually an attribute, but allows editing operations outside the preedit
area. value contains a QVariant of type string that specifies the text to
insert. start and length can specify regions outside the preedit area and
specify the text to be removed.
This allows inserts (length=0), deletes (string empty) and replaces of text
outside the preedit area.
Language:
The variant contains a QLocale object specifying the language of the preedit
string.
One question here: Is it enough to have one language for the whole event or
do you need to split it up into several for the preedit string? IMO one
language tag for the whole string should be enough.
RubyText:
The ruby text for the preedit string.
Please tell me what you think of this structure as I would like to implement
it as soon as possible.
Best regards,
Lars
More information about the immodule-qt
mailing list