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.
try instead of LD just D:
printf("Cursor Position = %d\n", cursor_pos);
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
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.