How to get position of cursor in string gadget

3 posts / 0 new
Last post
ktadd
ktadd's picture
Offline
Last seen: 8 months 3 weeks ago
Joined: 2010-12-01 01:20
How to get position of cursor in string gadget

I'm trying to read the current position of the cursor in a string gadget. This is what I tried which doesn't seem to work.

ULONG cursor_pos;

return_val =(Iintuition->GetAttrs(Object *)gadgets[GID_TITLE_TEXT], STRINGA_DispPos, &cursor_pos, TAG_DONE);
printf("Cursor Position = %ld \n", cursor_pos);

Cursor position is alway 0. I'm out of ideas. Any help!
====================================================

OK, got t. I neededto use the STRINGA_BufferPos tag as STRINGA_DispPos appears to only be valid when the gadget is active.

IIntuition->GetAttr(STRINGA_BufferPos, (Object *)gadgets[GID_TITLE_TEXT], &cursor_pos);

Also, the autodocs say that the data value for STRINGA_BufferPos is an int16 but it's actually a uint32.

jabirulo
jabirulo's picture
Offline
Last seen: 6 hours 7 min ago
Joined: 2013-05-30 00:53
Re: How to get position of cursor in string gadget

try instead of LD just D:

printf("Cursor Position = %d\n", cursor_pos);

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

thomas
thomas's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 2011-05-16 14:23
Re: How to get position of cursor in string gadget

STRINGA_DispPos is the position in the string of the first character in the display. It is usually 0 unless the string is longer than the display and the cursor is far right.

The result of GetAttr is always a uint32 regardless of the internal type. But if the autodocs say that it is a int16, you can be sure that you never see a value higher than 32767 there. And you must not set it to a higher value.

Log in or register to post comments