Thanks Mattias. Thinking about it now, the problem makes sense. Made the change and it works perfectly now!
I am very impressed with CodeTools so far! I have only scratched the surface of what it can do, but it is brilliant. Once you get the basics of how it works and what each class does, it becomes much easier. I took me much longer to write this addon for Kylix, than for Lazarus, thanks to CodeTools, which did most of the work for me. Regards, - Graeme - On 2/27/06, Mattias Gaertner <[EMAIL PROTECTED]> wrote: > On Mon, 27 Feb 2006 11:36:39 +0200 > "Graeme Geldenhuys" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I created a Lazarus addon which shows a list of procedures in a Modal > > dialog (same a GExperts Procedure List). Everythings seems to work > > fine, except for the editor focus after the jump. > > > > When I call the method below, it jumps to the correct location, and > > the Modal dialog closes, but now I cannot see my cursor in the editor? > > The editor looks like it has focus, but no cursor movement is shown > > when I press the up/down keys or even the Ctrl+up/down keys. > > > > Any ideas how I can resolve this? If you need the full source, I can > > email it directly. > > > > Some notes on the code below: > > LV = TListView component in Report style > > lItem.SubItems[3] holds the TCodeTreeNode.PosStart integer value > > > > > > > > procedure TProcedureListForm.JumpToSelection; > > var > > lItem: TListItem; > > Caret: TCodeXYPosition; > > NewTopLine: integer; > > CodeBuffer: TCodeBuffer; > > ACodeTool: TCodeTool; > > lStartPos: integer; > > begin > > lItem := LV.Selected; > > if lItem = nil then > > Exit; //==> > > if lItem.SubItems[3] = '' then > > Exit; //==> > > > > lStartPos := StrToInt(lItem.SubItems[3]); > > > > CodeBuffer := CodeToolBoss.FindFile(MainFilename); > > if CodeBuffer = nil then > > Exit; //==> > > > > ACodeTool := nil; > > CodeToolBoss.Explore(CodeBuffer,ACodeTool,false); > > if ACodeTool = nil then > > Exit; //==> > > > > if not ACodeTool.CleanPosToCaretAndTopLine(lStartPos, Caret, NewTopLine) > > then > > Exit; //==> > > > > LazarusIDE.DoOpenFileAndJumpToPos(Caret.Code.Filename, > > Point(Caret.X, Caret.Y), > > NewTopLine, -1, [ofRegularFile,ofUseCache]); > > The form is still modal, so the source editor can not be focused. Move the > above line behind the ShowModal. > Save the needed values in some public properties. > > > > > > Close; > > end; > > > > > > { method the launches the dialog } > > procedure ExecuteProcedureList(Sender: TObject); > > begin > > with TProcedureListForm.Create(Application) do > > try > > ShowModal; > > Add here: > > if ShowModal=mrOk then > LazarusIDE.DoOpenFileAndJumpToPos ... > > > > finally > > Free; > > end; > > end; > > Mattias > > _________________________________________________________________ > To unsubscribe: mail [EMAIL PROTECTED] with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives > _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives