Page 1 of 1

#ATTRCURSORX for Brushes

Posted: Fri Jan 17, 2020 3:47 pm
by evil
Hiho!

When printing directly onto the display, GetAttribute(#Display,id,#ATTRCURSORX) gives me the actual cursor position, where the next text would be printed.
Is there an equivalent for brushes??

Re: #ATTRCURSORX for Brushes

Posted: Mon Jan 20, 2020 11:22 pm
by airsoftsoftwair
You mean when using SelectBrush() mode?

Re: #ATTRCURSORX for Brushes

Posted: Tue Jan 21, 2020 12:44 am
by evil
Correct.

I create a brush, select it and print some text in it. Afterwards I need the actual cursor-position inside the brush.
It must be set somewhere, because when printing more text into the brush, It will be printed right after the first text...

Re: #ATTRCURSORX for Brushes

Posted: Tue Jan 21, 2020 10:10 pm
by airsoftsoftwair
Ok, so the way this works is that the cursor position is always reset to 0:0 when calling SelectBrush(). When calling EndSelect(), the old cursor position is restored. Maintaining an individual cursor position for every brush is probably overkill but you could easily stuff this into into your brush objects using SetObjectData(), e.g.

Code: Select all

; use this instead of SelectBrush()
Function p_MySelectBrush(id)
     Local cursor_x = GetObjectData(#BRUSH, id, "cursor_x")
     Local cursor_y = GetObjectData(#BRUSH, id, "cursor_y")
     SelectBrush(id)
     Locate(cursor_x, cursor_y)
EndFunction

; use this instead of EndSelect()
Function p_MyEndSelectBrush(id)
    Local cursor_x = GetAttribute(#DISPLAY, 0, #ATTRCURSORX)
    Local cursor_y = GetAttribute(#DISPLAY, 0, #ATTRCURSORY)
    SetObjectData(#BRUSH, id, "cursor_x", cursor_x)
    SetObjectData(#BRUSH, id, "cursor_y", cursor_y)
    EndSelect
EndFunction

Re: #ATTRCURSORX for Brushes

Posted: Tue Jan 21, 2020 11:55 pm
by evil
Cool! That helps a lot!

Thanks for the hint

Best regards

George!