How to put cursor into start position | developer.brewmp.com How to put cursor into start position | developer.brewmp.com

Developer

How to put cursor into start position

Forums:

Hi!

 

We're using following method to put cursor into start position (code fragments):

 

 

//--------------------------------------

IWidget *piwTextTo;

 

..........

 

nErr = ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_TextWidget, (void **)&(piwTextTo));

if (AEE_SUCCESS != nErr) {

return nErr;

}

 

 

.........

 

IWIDGET_SetText(piwTextTo, pSaved->pFromTo, FALSE);

 

 

set_cursor_into_start_position(piwTextTo);

 

 

 

//----------------------------------

void set_cursor_into_start_position(IWidget *pii)

{

TextInfo pTI;

ITextModel *pTextModel;

 

int err0 = 1;

int err1 = 1;

 

IWidget_GetModel(pii, AEEIID_ITextModel, CAST(IModel**, &pTextModel));

 

ITextModel_GetTextInfo(pTextModel, &pTI);

 

while(pTI.nSelEndCaret>0)

{

if (err0)

err0 = IWidget_HandleEvent(pii, EVT_KEY, AVK_LEFT, 0);

if (err1)

err1 = IWidget_HandleEvent(pii, EVT_KEY, AVK_UP, 0);//KB_AUTOREPEAT

ITextModel_GetTextInfo(pTextModel, &pTI);

}

 

IQI_RELEASEIF(pTextModel);

}

 

//-----------------------------------

It works perfectly in simulator, but crashes application on real device.

What is the best way to to put cursor into start position?

What is the best way to put cursor into any position inside text widget?

 

Best regards,

Benny

 

Text widget automatically manages caret/cursor. Not sure about your exact requirement but you can use ITextModel_SetSel() on text model to set caret position. E.g. to set cursor to start use: ITextModel_SetSel(pMe->pTextModel, 0, 0);

Text widget automatically manages caret/cursor. Not sure about your exact requirement but you can use ITextModel_SetSel() on text model to set caret position. E.g. to set cursor to start use: ITextModel_SetSel(pMe->pTextModel, 0, 0);

Thanks

Thanks