Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text Service



What I still don't get is at least what parameters do I have to "return" using SetEventParameter function to position the palette. From the name of the parameter, if kEventParamTextInputSendTextOffset is the one I need at minimum, how do I set the QD coordinates in typeLongInteger?

Any xxxSendyyy parameter is sent to you by the input method in the event.  You do not specify any of these, you just use the info.  The send/reply paradigm is relative to the originator of the Carbon event, i.e. the input method itself.

You insert into the event any xxxReplyzzz parameters that are "required" (if the offset is valid) such as:
    kEventParamTextInputReplyPoint

and insert any "optional" xxxReplyzzz parameters you desire, such as:
    kEventParamTextInputReplyFMFont (or kEventParamTextInputReplyFont with FMFontFamily/FOND)
    kEventParamTextInputReplyPointSize
    kEventParamTextInputReplyLineHeight
    kEventParamTextInputReplyLineAscent
    kEventParamTextInputReplyTextAngle

Pseudocode:

long        sendOffset;
status = GetEventParameter( inEvent, kEventParamTextInputSendTextOffset, typeLongInteger, NULL, sizeof(offset), NULL, &sendOffset );

if (fHaveInlineSession)
{
    offset = fInlineSession.begin + sendOffset  // offset is relative to beginning of inline session
    if (sendOffset < 0 || sendOffset >= fInlineSession.length)
        status = errOffsetInvalid;
}
else
{
    offset = fSelectedTextRange.begin + sendOffset  // If no selection, this means insertion-point relative offset
    if (offset < 0 || offset > fDocument.length)
        status = errOffsetInvalid;
}
require_noerr( status, OffsetToPosHandler_Fatal );

ATSUFontID    fmFont;  // or FMFont
long                    fontSize;
SInt16                lineHeight, ascent;

thePt = MyCharToPos( offset, &ascent, &lineHeight, &fmFont, &fontSize )

//  Required reply parameters
thePt.v += lineHeight;  // Push the point below our line, so the input method palette doesn't obscure the inline session
status = SetEventParameter( inEvent, kEventParamTextInputReplyPoint, typeQDPoint, sizeof( Point ), &thePt );

//  Optional reply parameters
Fixed tempFixed = LongToFixed( fontSize );
status = SetEventParameter( inEvent, kEventParamTextInputReplyPointSize, typeFixed, sizeof( Fixed ), &tempFixed );

status = SetEventParameter( inEvent, kEventParamTextInputReplyLineHeight, typeShortInteger, sizeof( short ), &lineHeight );
status = SetEventParameter( inEvent, kEventParamTextInputReplyLineAscent, typeShortInteger, sizeof( short ), &ascent );

status = SetEventParameter( inEvent, kEventParamTextInputReplyFMFont, typeUInt32, sizeof( UInt32 ), &fmFont );

OffsetToPosHandler_Fatal:
return status;

how do I set the QD coordinates in typeLongInteger?
You don't.  The kEventParamTextInputReplyPoint event parameter is typed as typeQDPoint

On Mar 30, 2005, at 8:46 AM, Norio Ota wrote:

Really really sorry about lack of my understanding. I'm still stuck in the header.


I went to see "kEventClassTextInput/kEventTextInputOffsetToPos" in the header. What I still don't get is at least what parameters do I have to "return" using SetEventParameter function to position the palette. From the name of the parameter, if kEventParamTextInputSendTextOffset is the one I need at minimum, how do I set the QD coordinates in typeLongInteger?


Best regards,

Norio Ota


On 2005年 3月 29日 , at 10:13 AM, Michael Grady wrote:



Does "return" mean to make new event and set the position info to the event

and send it to an event target or something in the handler?


No new event.  You simply set the "return" parameters (specified in the header) directly in the event passed in to your handler.  You do not need to dispatch the event any further.  When your handler replies (returns an error/noErr) to TSM, TSM takes care of communicating your info back to the input method.

Michael Grady


On Mar 28, 2005, at 4:53 PM, Norio Ota wrote:



Thanks for your kind help.


Can I ask you further question about the second one?


What I still don't understand is that I'm not sure how to write codes in the


event's handler to "return" the position of the insertion point.


Does "return" mean to make new event and set the position info to the event


and send it to an event target or something in the handler?



Best regards,


Norio Ota



On 2005年 3月 28日 , at 11:42 PM, Alexey Proskuryakov wrote:




On 28.03.2005 17:22, "Norio Ota" <email@hidden> wrote:




Would you tell me where I should put TSMSetInlineInputRegion function,




  The headers say: "when the text content of the inline input session


content changes (i.e. due to Update Active Input Area events) and when the


region moves for other reasons, such as window resized, scrolling, etc.".



  In other words, each time the position or size of the inline input area


changes. Sounds non-trivial, as there will unlikely be a single bottleneck


where to make this call.



  Of course, one only needs this in a custom text engine.




and what I should actually write in the Carbon text input event


kEventTextInputOffsetToPos?




  Well, it's asking for a point "near" the character at


kEventParamTextInputSendTextOffset. I do not have a real answer, but the


Kotoeri palette should appear at the same position it does for Apple's text


controls, so it should be easy enough to decide empirically :)



- WBR, Alexey Proskuryakov










 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: Text Service (From: Alexey Proskuryakov <email@hidden>)
 >Re: Text Service (From: Norio Ota <email@hidden>)
 >Re: Text Service (From: Michael Grady <email@hidden>)
 >Re: Text Service (From: Norio Ota <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.