[Lazarus] Showing selection on drawing under Cocoa

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Showing selection on drawing under Cocoa

Free Pascal - Lazarus mailing list
Is there an easy way of indicating a selection on a plot in Cocoa? I
have a plot that is relatively time consuming to plot (particularly
under Cocoa), and I want to be able to indicate the area selected with a
mouse. On other widget sets I can xor a rectangle and do this quickly in
the mouse event handler, but this is not possible under Cocoa because
you can only plot during a paint event, so I have to invalidate the
selected area and redraw the entire plot just to show a selection.

Am I missing something? How does the Cocoa toolkit expect this to be done?

Colin

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Showing selection on drawing under Cocoa

Free Pascal - Lazarus mailing list
On Wed, Oct 16, 2019 at 4:33 PM C Western via lazarus <[hidden email]> wrote:
Am I missing something? How does the Cocoa toolkit expect this to be done?
I'm see 3 ways of doing that.
1) you just invalidate the needed rectangle lines (or the entire selected area) and do xor drawing  on paint event.

2) you might want to try to play with "focusRing" settings of NSView. That requires Cocoa level access to the view. Not cross platform, obviously.

3) instead of drawing into the view itself, you might want to create a semi-transparent window or a control, to be at the top of the hierarchy.
and draw a focus as an overlay. Obviously you want this window or control to ignore any keyboard or mouse events (not to interfere with underlying controls).
The solution can be cross platform.

Approach #1 seems to be the easiest at this point.

thanks,
Dmitry

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Showing selection on drawing under Cocoa

Free Pascal - Lazarus mailing list
On 17/10/2019 03:44, Dmitry Boyarintsev via lazarus wrote:

> On Wed, Oct 16, 2019 at 4:33 PM C Western via lazarus
> <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>     Am I missing something? How does the Cocoa toolkit expect this to
>     be done?
>
> I'm see 3 ways of doing that.
> 1) you just invalidate the needed rectangle lines (or the entire
> selected area) and do xor drawing  on paint event.

I hadn't thought of that possibility at all - thank you! (It obviously
requires some work on the paint handler, but this is likely to be the
most straightforward.)

Colin


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Showing selection on drawing under Cocoa

Free Pascal - Lazarus mailing list
On 17/10/2019 08:09, C Western via lazarus wrote:

> On 17/10/2019 03:44, Dmitry Boyarintsev via lazarus wrote:
>> On Wed, Oct 16, 2019 at 4:33 PM C Western via lazarus
>> <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     Am I missing something? How does the Cocoa toolkit expect this to
>>     be done?
>>
>> I'm see 3 ways of doing that.
>> 1) you just invalidate the needed rectangle lines (or the entire
>> selected area) and do xor drawing  on paint event.
>
> I hadn't thought of that possibility at all - thank you! (It obviously
> requires some work on the paint handler, but this is likely to be the
> most straightforward.)
>
>
Sadly this doesn't work on Cocoa; it works fine under windows, but for
Cocoa (and all the other widgetsets I tried) calling invalidate erases
the contents of the rectangle, and I couldn't find any way to turn off
this behavior. Unless this is possible, I will have to try a transparent
window.

Colin


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus