PtText

Hello,
I have a window with a text widget for input. Is there a way to open up the
window and have a cursor blinking in the text widget ? This would let the
user know that he has to enter data in the text widget.

Thank you,
Shashank

I hope someone can help me with this question.

Shashank

“Shashank” <sbalijepalli@precitech.com> wrote in message
news:aqublr$25q$1@inn.qnx.com

Hello,
I have a window with a text widget for input. Is there a way to open up
the
window and have a cursor blinking in the text widget ? This would let the
user know that he has to enter data in the text widget.

Thank you,
Shashank

There is no convenient flags to enable/disable cursor blinking for PtText in
QNX4 Photon. You will have to do it in your code. Please look at a code
sample which will do it for you.
My implementation:

  • got_focus_cb() is a Pt_CB_GOT_FOCUS callback on your PtText widget(s):
    arms the timer.
  • lost_focus_cb() is a Pt_CB_LOST_FOCUS callback: disarms the timer and
    sets the Pt_CURSOR_VISIBLE in the Pt_ARG_TEXT_FLAGS.
  • timer_cb() is a raw callback (event mask is Ph_EV_TIMER): re-arms the
    timer and toggles the Pt_CURSOR_VISIBLE.

-Misha.

— cut here —
#define BLINK_RATE 200

/*********************************************************** GOT_FOCUS_CB()
***/
int
got_focus_cb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
{
PtTimerArm( widget, BLINK_RATE );
return( Pt_CONTINUE );
}

/********************************************************** LOST_FOCUS_CB()
***/
int
lost_focus_cb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
{
PtTimerArm( widget, 0 );
{
PtArg_t arg;
PtSetArg( &arg, Pt_ARG_TEXT_FLAGS, Pt_CURSOR_VISIBLE, Pt_CURSOR_VISIBLE );
PtSetResources( widget, 1, &arg );
}
return( Pt_CONTINUE );
}

/*************************************************************** TIMER_CB()
***/
int
timer_cb( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
long *flags;
PtArg_t arg;

PtSetArg( &arg, Pt_ARG_TEXT_FLAGS, &flags, 0 );
PtGetResources( widget, 1, &arg );

PtSetArg( &arg, Pt_ARG_TEXT_FLAGS,
( *flags & Pt_CURSOR_VISIBLE ) ? 0 : Pt_CURSOR_VISIBLE,
Pt_CURSOR_VISIBLE );
PtSetResources( widget, 1, &arg );

PtTimerArm( widget, BLINK_RATE );

return( Pt_CONTINUE );
}


“Shashank” <sbalijepalli@precitech.com> wrote in message
news:ar0h07$frq$1@inn.qnx.com

I hope someone can help me with this question.

Shashank

“Shashank” <> sbalijepalli@precitech.com> > wrote in message
news:aqublr$25q$> 1@inn.qnx.com> …
Hello,
I have a window with a text widget for input. Is there a way to open up
the
window and have a cursor blinking in the text widget ? This would let
the
user know that he has to enter data in the text widget.

Thank you,
Shashank
\