Page 1 of 1

drag within RVEdit

Posted: Thu Apr 09, 2015 12:58 pm
by Jim Knopf
After successless trials I ask you, Sergey, how to solve that problem. It looks simple in the first moment but only in the first. Perhaps you have some methods somewhere?

User selects one or some words and drags it so another place (in the same edit). At source position the second space (behind the word(s)) should disappear and at target position it should be insertet before/behind (depending on drop position). So far so good this simple problem I solved. But if there are more items or more items selected for moving I run into brain overflow ;-)

Posted: Fri Apr 10, 2015 6:30 am
by Sergey Tkachenko
Sorry, I do no understand. can you describe the problem with more details?

Posted: Fri Apr 10, 2015 7:38 am
by Jim Knopf
Yes of course.

User writes these items:

"User selects one or some words.
Drags them so another place in the same edit. At source position the second space (behind the word(s)) should disappear and at target position."

Then he selects a part of it to move it somwhere else (red=selected words) ...

"User selects one or some words.
Drags them so another place in the same edit. At source position the second space (behind the word(s)) should disappear and at target position."

... and moves it with the mouse to another place:

"User selects one or some words.
Drags them so another place . At source position the second spacein the same edit (behind the word(s)) should disappear and at target position."

Now there is one space before the conclusing point of the first sentence and no space between 'space' and 'in'.

In the moment I solved it in a bit complicated way:

1. At OnSelect I copy the selected words to a variable 'FInternalMoveText'
2. At OnItemAction this code:

Code: Select all

  if (FScreenplayConv and FHasScreenplay) or FClosing then
    Exit; // <<<<<<<<<<<<<<<<<<<<<< EXIT

  if not FStyleChanging and (ItemAction = rviaInserting) and (Text <> '') and not FTextLoading and
     not FSelectingChars and (Text = FInternalMoveText) and (Length(Text) > 1) then
  begin
    Text := Format(' %s ', [Text]);  // <-------------------------------------------
    tiCleanUp.Enabled := True;   // <-------------------------------------------
  end;
3. At OnTimer I call a method to correct the missing or double spaces (and more) at the source item and the target item: delete double spaces, paying attention to start/end of item, delimiters a.s.o.

a) I don't like timers because they can cause unexpected side effects
b) This method works but it feels not stable nevertheless.

I tried out another way: delete or insert spaces at the source- and target positions and it worked. But only for simple moving from words between words. And that was complicated yet. And I didn't consider all the special options like 'only one word in Item', target/source is last/first in item and a lot more. So I went back to the way described above. But I am not lucky with it. So I thought perhaps you have a more professional solution, because I think it is the problem of more or less everybode who uses TRichViewEdit.

Posted: Fri Apr 10, 2015 7:47 am
by Sergey Tkachenko
If I understand...
If the user inserts here (at the place if "|"):
"second space |(behind "
the result will be as expected.

But if the user inserts here:
"second space| (behind "
you want to make adjustments to provide correct results.

Sorry, we do not want to implement this feature in near future.