Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-08

Need your thoughts on Caret

11 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Micha Nelissen
to Michael Van Canneyt: The keypress problem is more general: none of the examples respond to keypresses, except…
Michael Van Canneyt wrote 30 lines
On Tue, 12 Aug 2003, Micha Nelissen wrote: >Mattias Gaertner wrote: > > >>On Mon, 11 Aug 2003 20:56:52 +0200 >>Micha Nelissen wrote: >> >> >> >>>If you trace code flow you will see that ShowCaret indeed returns false >>>most of the time if not always. >>> >>>Since this involves more than simply adjusting the win32 interface, I >>>ask for your thoughts on this. >> >> >>You mean, changing the synedit code? >>The caret showing code in synedit has not much changed for the LCL. Does the >>synedit1 example work under win32 intf? > >Exactly what I expected! The caret *seems* to work, ie. it appears (but >does not respond to keypresses). The keypress problem is more general: none of the examples respond to keypresses, except where a native windows widget is used. Custom key handling doesn't work anywhere. So that is not related to the caret...

OK, will place that on the TODO. But right now, I'm interested in that caret functionality...has the synedit caret ever worked correctly then? Also when focus was removed and restored?

Micha.

Reply by email

Mattias Gaertner
to Micha Nelissen: The SynEdit creates a caret to display. This is implemented in the win32 interface, but…
Show quoted text 14 lines
Hi, The SynEdit creates a caret to display. This is implemented in the win32 interface, but the win32 interface needs it to be created on *every* setfocus. That is, when you lose focus, you hide & destroy your caret, then when you get focus, you need to create & show the caret. Help from win32sdk on ShowCaret: <snip> ShowCaret shows the caret only if the specified window owns the caret, the caret has a shape, and the caret has not been hidden two or more times in a row. If one or more of these conditions is not met, ShowCaret does nothing and returns FALSE. </snip>

What do "the specified window owns the caret" and "the caret has a shape" mean?

Show quoted text 5 lines
If you trace code flow you will see that ShowCaret indeed returns false most of the time if not always. Since this involves more than simply adjusting the win32 interface, I ask for your thoughts on this.

You mean, changing the synedit code?
The caret showing code in synedit has not much changed for the LCL. Does the synedit1 example work under win32 intf?

Mattias

Reply by email

Micha Nelissen
to Micha Nelissen: The SynEdit creates a caret to display. This is implemented in the win32 interface, but…
Mattias Gaertner wrote 14 lines
On Mon, 11 Aug 2003 20:56:52 +0200 Micha Nelissen wrote: >If you trace code flow you will see that ShowCaret indeed returns false >most of the time if not always. > >Since this involves more than simply adjusting the win32 interface, I >ask for your thoughts on this. You mean, changing the synedit code? The caret showing code in synedit has not much changed for the LCL. Does the synedit1 example work under win32 intf?

Exactly what I expected! The caret *seems* to work, ie. it appears (but does not respond to keypresses). Anyway, when you remove focus, ie. ALT-TAB, then back, the caret is gone, and won't reappear.

Have I explained the problem clearly enough?

Micha.

Reply by email

Micha Nelissen
to Micha Nelissen: The SynEdit creates a caret to display. This is implemented in the win32 interface, but…
Mattias Gaertner wrote 19 lines
On Mon, 11 Aug 2003 20:56:52 +0200 Micha Nelissen wrote: >Hi, > >The SynEdit creates a caret to display. This is implemented in the win32 >interface, but the win32 interface needs it to be created on *every* >setfocus. That is, when you lose focus, you hide & destroy your caret, >then when you get focus, you need to create & show the caret. Help from >win32sdk on ShowCaret: > ><snip> >ShowCaret shows the caret only if the specified window owns the caret, >the caret has a shape, and the caret has not been hidden two or more >times in a row. If one or more of these conditions is not met, ShowCaret >does nothing and returns FALSE. ></snip>

The documentation is vague, but this is what I make of it:

What do "the specified window owns the caret"

You've called CreateCaret recently enough.

and "the caret has a shape" mean?

The CreateCaret call was succesfull and you've supplied the same window to CreateCaret as ShowCaret. It seems to do these both things at once.

<snip>
The CreateCaret function creates a new shape for the system caret and assigns ownership of the caret to the specified window. The caret shape can be a line, a block, or a bitmap.

CreateCaret automatically destroys the previous caret shape, if any, regardless of the window that owns the caret. The caret is hidden until the application calls the ShowCaret function to make the caret visible.

The caret is a shared resource; there is only one caret in the system. A window should create a caret only when it has the keyboard focus or is active. The window should destroy the caret before losing the keyboard focus or becoming inactive.
</snip>

Show quoted text 10 lines
>If you trace code flow you will see that ShowCaret indeed returns false >most of the time if not always. > >Since this involves more than simply adjusting the win32 interface, I >ask for your thoughts on this. You mean, changing the synedit code? The caret showing code in synedit has not much changed for the LCL. Does the synedit1 example work under win32 intf?

I will investigate this.

Micha.

Reply by email

Marc Weustink
to Mattias Gaertner: On Tue, 12 Aug 2003 12:07:11 +0200 I never tried synedit under win32 interface. To the…

+ From: Mattias Gaertner
+ Sent: dinsdag 12 augustus 2003 15:52
+
+ On Tue, 12 Aug 2003 12:07:11 +0200
+ Micha Nelissen wrote:
+
+ > Michael Van Canneyt wrote:
+ >
+ > > The keypress problem is more general: none of the examples respond to
+ > > keypresses, except where a native windows widget is used. Custom key
+ > > handling doesn't work anywhere. So that is not related to the caret...
+ >
+ > OK, will place that on the TODO. But right now, I'm interested in that
+ > caret functionality...has the synedit caret ever worked correctly then?
+ > Also when focus was removed and restored?
+
+ I never tried synedit under win32 interface.
+
+ To the keypress:
+ WM_KEYDOWN messages are sent in the win32 intf as LM_SYSKEYDOWN.
+ I thought, LM_SYSKEYDOWN is for system keys like Alt+X. I changed that.
+ Maybe you can check that.

WM_KEYDOWN should generate LM_KEYDOWN and WM_SYSKEYDOWN should generate LM_SYSKEYDOWN.

Syskeys are indeed keys with ALT+key

Marc

Reply by email

Michael Van Canneyt
to Micha Nelissen: Exactly what I expected! The caret *seems* to work, ie. it appears (but does not respond…
Micha Nelissen wrote 19 lines
Mattias Gaertner wrote: > On Mon, 11 Aug 2003 20:56:52 +0200 > Micha Nelissen wrote: > > >>If you trace code flow you will see that ShowCaret indeed returns false >>most of the time if not always. >> >>Since this involves more than simply adjusting the win32 interface, I >>ask for your thoughts on this. > > > You mean, changing the synedit code? > The caret showing code in synedit has not much changed for the LCL. Does the > synedit1 example work under win32 intf? Exactly what I expected! The caret *seems* to work, ie. it appears (but does not respond to keypresses).

The keypress problem is more general: none of the examples respond to keypresses, except where a native windows widget is used. Custom key handling doesn't work anywhere. So that is not related to the caret...

Michael.

Reply by email

Marc Weustink
to Marc Weustink: What is the case, why is it false ? You're not the owner ? It has no shape ? It't is…
Micha Nelissen wrote
Marc Weustink wrote: >At 20:56 11-8-2003 +0200, Micha Nelissen wrote:

[snip]

Show quoted text 7 lines
>>If you trace code flow you will see that ShowCaret indeed returns false >>most of the time if not always. > >What is the case, why is it false ? >You're not the owner ? Yes.

??? The doc's are a bit misty in this, but it looks like if you use ShowCaret(hwnd) you are the owner.

>It has no shape ? No, CreateCaret returns true when it's called, but that's only once.

You are creating a Caret with or without bitmap (knowing the SynEdit code i gues without)

Show quoted text 11 lines
>It't is pretty good hidden ? If Hide / Show are balanced well, this should not be a problem. >>Since this involves more than simply adjusting the win32 interface, I >>ask for your thoughts on this. > >Why adjusting the interface ? It's the win32 api that is quirky on this, I mean the fact that you have to recreate and destroy your caret continously.

Ehm... I think you dont have to worry about that. SynEdit is originally a Delphi project where synedit itself creates the caret. The win32 interface has nothing else to do than just passing through the calls. So I don't get why you are creating carets.

Marc

Reply by email

Mattias Gaertner
to Michael Van Canneyt: The keypress problem is more general: none of the examples respond to keypresses, except…
Show quoted text 36 lines
Michael Van Canneyt wrote: > > On Tue, 12 Aug 2003, Micha Nelissen wrote: > > >>Mattias Gaertner wrote: >> >> >>>On Mon, 11 Aug 2003 20:56:52 +0200 >>>Micha Nelissen wrote: >>> >>> >>> >>>>If you trace code flow you will see that ShowCaret indeed returns >false>>>most of the time if not always. >>>> >>>>Since this involves more than simply adjusting the win32 interface, I >>>>ask for your thoughts on this. >>> >>> >>>You mean, changing the synedit code? >>>The caret showing code in synedit has not much changed for the LCL. >Does the>>synedit1 example work under win32 intf? >> >>Exactly what I expected! The caret *seems* to work, ie. it appears (but >>does not respond to keypresses). > > > The keypress problem is more general: none of the examples respond to > keypresses, except where a native windows widget is used. Custom key > handling doesn't work anywhere. So that is not related to the caret... OK, will place that on the TODO. But right now, I'm interested in that caret functionality...has the synedit caret ever worked correctly then? Also when focus was removed and restored?

I never tried synedit under win32 interface.

To the keypress:
WM_KEYDOWN messages are sent in the win32 intf as LM_SYSKEYDOWN. I thought, LM_SYSKEYDOWN is for system keys like Alt+X. I changed that. Maybe you can check that.

To the caret:
The gtk-interface supports one caret per handle and carets that don't hide on lost focus. CreateCaret and DestroyCaret are nearly automatically called. And so the bug of Create/DestroyCaret calls in the synedit never appeared under gtk. The calls are not balanced in synedit. I fixed thst for the focus messages.

I will commit as soon as the server is back.
I can now edit some text in the synedit example under win32 intf. But it is flickering and the client width/height is not correct.

Mattias

Reply by email

Marc Weustink
to Micha Nelissen: The SynEdit creates a caret to display. This is implemented in the win32 interface, but…
Micha Nelissen wrote 17 lines
Hi, The SynEdit creates a caret to display. This is implemented in the win32 interface, but the win32 interface needs it to be created on *every* setfocus. That is, when you lose focus, you hide & destroy your caret, then when you get focus, you need to create & show the caret. Help from win32sdk on ShowCaret: <snip> ShowCaret shows the caret only if the specified window owns the caret, the caret has a shape, and the caret has not been hidden two or more times in a row. If one or more of these conditions is not met, ShowCaret does nothing and returns FALSE. </snip> If you trace code flow you will see that ShowCaret indeed returns false most of the time if not always.

What is the case, why is it false ?
You're not the owner ?
It has no shape ?
It't is pretty good hidden ?

Since this involves more than simply adjusting the win32 interface, I ask for your thoughts on this.

Why adjusting the interface ?

Marc

Reply by email

Micha Nelissen
to Marc Weustink
Marc Weustink wrote 23 lines
At 20:56 11-8-2003 +0200, Micha Nelissen wrote: > Hi, > > The SynEdit creates a caret to display. This is implemented in the > win32 interface, but the win32 interface needs it to be created on > *every* setfocus. That is, when you lose focus, you hide & destroy > your caret, then when you get focus, you need to create & show the > caret. Help from win32sdk on ShowCaret: > > <snip> > ShowCaret shows the caret only if the specified window owns the caret, > the caret has a shape, and the caret has not been hidden two or more > times in a row. If one or more of these conditions is not met, > ShowCaret does nothing and returns FALSE. > </snip> > > If you trace code flow you will see that ShowCaret indeed returns > false most of the time if not always. What is the case, why is it false ? You're not the owner ?

Yes.

It has no shape ?

No, CreateCaret returns true when it's called, but that's only once.

It't is pretty good hidden ?

If Hide / Show are balanced well, this should not be a problem.

Show quoted text 5 lines
> Since this involves more than simply adjusting the win32 interface, I > ask for your thoughts on this. Why adjusting the interface ?

It's the win32 api that is quirky on this, I mean the fact that you have to recreate and destroy your caret continously.

Regards,

Micha.

Reply by email

Micha Nelissen

Hi,

The SynEdit creates a caret to display. This is implemented in the win32 interface, but the win32 interface needs it to be created on *every* setfocus. That is, when you lose focus, you hide & destroy your caret, then when you get focus, you need to create & show the caret. Help from win32sdk on ShowCaret:

<snip>
ShowCaret shows the caret only if the specified window owns the caret, the caret has a shape, and the caret has not been hidden two or more times in a row. If one or more of these conditions is not met, ShowCaret does nothing and returns FALSE.
</snip>

If you trace code flow you will see that ShowCaret indeed returns false most of the time if not always.

Since this involves more than simply adjusting the win32 interface, I ask for your thoughts on this.

Regards,

Micha.

Reply by email