View previous topic :: View next topic |
Author |
Message |
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Tue Jul 25, 2006 2:29 pm Post subject: Bookmark questions |
|
|
Apologies in advance if this long post is received twice. My connection went foobar when I attempted to post the first time.
I am finding the bookmarks design difficult to work with. Hopefully I am just misunderstanding the intended use of them.
Our product needs to support the standard 0-9 bookmarks that most editors provide. In addition, we need to support unlimited custom bookmarks that we create and maintain without the user's direct knowledge. I have looked at the demos and it appears that there is no differentiation between the 0-9 and any custom ones. This is fine as we can work around that to maintain an internal list of which bookmarks were set by the user via CTRL+SHIFT+[0..9], etc.
I have created my custom bookmarks when the user loads a file and they occupy BookmarkObj positions 0..N. I then attempt to goto the bookmark via GotoBookmark(MyBookmark.Index) and this does not work since GotoBookmark is looking for a match to BmIndex. My BmIndex for all custom bookmarks are 0 since I did not set the bookmark using the Bookmarks[I] := SomeOffset. This is how I am creating my bookmarks.
Code: | var
BM: TBookmark;
begin
BM := TestMemo.BookmarkObj.Add;
BM.Position := SomeOffset;
end; |
What is the difference between BmIndex and the TCollectionItem.Index property that we get for free in TBookmark? If there is a difference, can support be added to also set the BmIndex when BookmarkObj.Add is used? Am I completely missing the intended use of the bookmarks? If so, is it expected that one would have to use both of the properties in conjunction to achieve full results as in the following?
Code: | var
BM: TBookmark;
begin
BM := TestMemo.BookmarkObj.Add;
//BM.Position := SomeOffset;
TestMemo.Bookmarks[BM.Index] := SomeOffset;
end; |
Thanks. |
|
Back to top |
|
|
itsatomic
Joined: 12 Jun 2006 Posts: 38
|
Posted: Wed Jul 26, 2006 3:41 am Post subject: |
|
|
Hi mstaszew
Did you see the bookmark example I asked and received an answer for just yesterday? All you need to do is add the following line of code:
BM.BMIndex := YourIndex;
once you have made the suggestion Michael made about adding the write directive to the BMIndex property.
http://www.econtrol.ru/forum/viewtopic.php?t=26
HTH
Aaron |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Wed Jul 26, 2006 1:40 pm Post subject: |
|
|
I ended up adding an AddBookmark method ro my descendant class that is working quite well. A one line bookmark set can be performed now, but it doesn't handle hints, image indices, or the other gutter object properties but those can easily be added.
Code: | function TNewSyntaxMemo.AddBookmark(CharOffset: Integer): TBookmark;
begin
Result := BookmarkObj.Add;
Bookmarks[Result.ID] := CharOffset;
end; |
Thanks. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Wed Jul 26, 2006 8:14 pm Post subject: |
|
|
You should write following code:
Code: | function TNewSyntaxMemo.AddBookmark(CharOffset: Integer): TBookmark;
begin
Result := BookmarkObj.Add;
Result.Position := CharOffset;
// Bookmarks[Result.ID] := CharOffset;
end; |
Michael. |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Wed Jul 26, 2006 8:21 pm Post subject: |
|
|
I tried that initially, but then the GotoBookmark routine didn't seem to work. I would pass the BmIndex in GotoBookmark and all of my bookmarks had BmIndex = 0 since I never explicitly set it and since I never used the Bookmarks array.
So if I do use that code, how would I use the GotoBookmark routine?
Thanks. |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Wed Jul 26, 2006 8:38 pm Post subject: |
|
|
Ok, hang on. I think that I am starting to understand the bookmarks.
Are BmIndex's 0..9 reserved for the 0..9 bookmarks that are common to most editors? If so, does that mean that any custom bookmarks MUST use BmIndex > 9?
Thanks. |
|
Back to top |
|
|
|