Autor Beitrag
HaRaH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Sa 05.02.05 14:06 
hallo,
ich möchte in einem RichEdit-Feld die aktuelle Cursor-Position feststellen.
Hab gelesen, dass das über .SelAttributes geht - aber wie genau komm ich da an die Cursorposition?

danke im Vorraus!

Gruß MaX
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 05.02.05 14:34 
Hallo,

gugg dir mal die Eigenschaft CaretPos an

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
HaRaH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Sa 05.02.05 14:50 
danke erstmal, :D

aber damit kann ich noch nicht umsetzen, was ich wollte.
ich wollte mit

ausblenden Delphi-Quelltext
1:
StatusBar.Panels[2].Text := 'x:' + inttostr(Editor.CaretPos.x) + ', y: ' + inttostr(Editor.CaretPos.y);					


in der Statusbar die Cursorposition in einem Textfeld angeben. Aber irgendwie zeigt er mir da teilweise an verschiedenen Stellen die gleichen Koordinaten an. Zum Beispiel vor und hinter einem Buchstaben.
Wahrscheinlich liegt das daran, dass die Pixelposition und nicht die Zeichenstellenposition augegeben wird.
Mit SelStart kann man ebenfalls die Position ermitteln. Leider bekomme ich da aber nicht die Zeile raus, sondern nur, der wievielte Buchstabe das gerade ist. Das dafür sehr genau.

Hat jemand eine Idee, wie ich bei jedem Tastendruck genau ermitteln kann, in welcher Zeile und welcher Spalte sich der Cursor befindet :?:

thx - Gruß MaX

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 05.02.05 15:03 
wo hast du diesen code stehen?

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
HaRaH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Sa 05.02.05 15:07 
hab's in der OnKeyPress, OnKeyup und OnKeyDown - Prozedur versucht
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 05.02.05 15:18 
wenn nur um tastendrücke geht, wäre für mich onkeypress und keyup das richtige. Oder, noch besser, um gleich auf die maus zu reagieren: nur das onselectionchange-ereignis nutzen

auch sind die Werte immer von 0 an beginnend, also noch ein +1 bei den Werten. Es verhält sich so, wie der Delphi-Editor.

In dem Demo-Ordner ist auch ein Demo "Richedit", gugg auch mal dort.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
HaRaH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Sa 05.02.05 15:31 
onselectionchange reagiert leider nicht, wenn ich mit der Tastatur durch den Text gehe, ohne ihn zu verändern.
und auch wenn ich zu dem Wert, den mir CaretPos liefert 1 addieren, hab ich noch nicht das Problem gelöst, dass die Angabe nicht eindeutig ist. Deshalb steht in der Hilfe auch, man sollte lieber SelStart benutzen. Aber darüber bekomme ich leider keine Zeilen und Spaltennummer, sondern nur die Zeichennummer im gesamten Text.
:(
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 05.02.05 15:34 
tut mir leid, aber ich kann dein Problem nicht nachvollziehen. ich habe in einen Bsp-Projekt nur das onselectionchenge ereignis verwendet und es funktioniert.

Was für eine Delphi-version hast du?

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
HaRaH Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 65



BeitragVerfasst: Sa 05.02.05 15:40 
?! - ok - sorry - es funktioniert tatsächlich - hab mich vertan.
Ka warum, aber es funktioniert sogar erstaunlich gut.
:D perfekt! - Problem gelöst! - danke!

Gruß MaX