Recent

Author Topic: Added patch to enable OnChange support for CDEdit and CDComboBox  (Read 4840 times)

stab

  • Full Member
  • ***
  • Posts: 182
Added patch to enable OnChange support for CDEdit and CDComboBox
« on: November 20, 2012, 10:29:44 am »
Hi,

Added following changes to enable OnChange support for CDEdit and CDComboBox.

If this is OK, it could perhaps be added to Custom Drawn Components package.

procedure TCDComboBox.SetItemIndex(AValue: Integer);
var
  lValue : Integer;
  lText: String;
begin
  lValue := AValue;

  // First basic check
  if lValue >= FItems.Count then lValue := FItems.Count - 1;
  if lValue < -1 then lValue := -1;

  // Check if the text changed too, because it might differ from the choosen item
  FItemIndex:=lValue;
  if (lValue >= 0) and (lValue < FItems.Count)then
  begin
    lText := FItems.Strings[lValue];
    if Lines.Text = lText then Exit;
// MyChanges **************************************************
    if FItems.Count > 1 then
    begin
      Lines.Text := FItems.Text;
      if lValue < Lines.Count then
        DoChange;
    end;
// MyChanges **************************************************
    Text := lText;
  end;
  Invalidate;
end;

procedure TCDEdit.SetCurrentLine(AStr: string);
var
  oldStr : string;
begin
  if (FEditState.Lines.Count = 0) or (FEditState.CaretPos.Y >= FEditState.Lines.Count) then
  begin
    FEditState.Lines.Text := AStr;
    FEditState.VisibleTextStart.X := 1;
    FEditState.VisibleTextStart.Y := 0;
    FEditState.CaretPos.X := 0;
    FEditState.CaretPos.Y := 0;
  end
  else
  begin
    oldStr := FLines.Strings[FEditState.CaretPos.Y]; // MyChanges **************
    FLines.Strings[FEditState.CaretPos.Y] := AStr;
    if oldStr <> AStr then                           // MyChanges **************
      DoChange;                                      // MyChanges **************
  end;
end;

Regards
stab  ;)

stab

  • Full Member
  • ***
  • Posts: 182
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #1 on: November 20, 2012, 10:34:47 am »
Added also     
property OnChange : TNotifyEvent read FOnChange write FOnChange to
TCDEdit

/stab

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #2 on: November 20, 2012, 11:55:49 am »
Hello,

Please create a patch in our standard format, as explained in the wiki: http://wiki.freepascal.org/Creating_A_Patch

thanks,

stab

  • Full Member
  • ***
  • Posts: 182
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #3 on: November 20, 2012, 07:37:35 pm »
Hi Felipemdc,

I'll gladly do so, but I don't understand the instructions.

Platform:      Windows 7/64
Lazarus:       ver. 1.1
FPC:              ver.2.7.1 SVN Rev: 39275

Am I supposed to download "Lazarus SVN development version",   
i.e all within the trunk at http://svn.freepascal.org/svn/lazarus/trunk, over the oversion I already have???

Creating the patch using SVN

svn diff > mypatch.diff

Where do I find svn?

This includes all changed files in the whole SVN repository.
You can also define the individual files, to make sure no garbage is included, eg. :

svn diff ide/main.pp ideintf/objectinspector.pp > mypatch.diff


Regards and thank you for a good work
stab %)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3654
  • I like bugs.
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #4 on: November 20, 2012, 08:02:56 pm »
Am I supposed to download "Lazarus SVN development version",   
i.e all within the trunk at http://svn.freepascal.org/svn/lazarus/trunk, over the oversion I already have???

No, download it into a new directory.

Quote
Where do I find svn?

You could try TortoiseSVN. Remember to include cmd line tools during the installation.

Quote
svn diff ide/main.pp ideintf/objectinspector.pp > mypatch.diff

In your case it would be :
 svn diff lcl/customdrawncontrols.pas > mypatch.diff
[edit: the file ending does not really matter, can be .patch or .diff]

Juha
« Last Edit: November 21, 2012, 09:53:53 am by JuhaManninen »

stab

  • Full Member
  • ***
  • Posts: 182
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #5 on: November 21, 2012, 09:14:31 pm »
OK,

I managed to get Lazarus SVN development version via Tortoise to a new directory.  Changed to the directory where the development version was downloaded and issued:
 svn diff lcl/customdrawncontrols.pas > stab.patch

stab.patch sure got created but it is empty.

I guess I'm supposed to specify where the file with my changes is but where do I do that?

Regards
stab %)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #6 on: December 21, 2012, 11:35:00 am »
You made a wrong command, it should be like this:

cd lazarus
svn diff > stab.patch

And then you can delete parts that you don't want manually from the file stab.patch if you only want some files.

Anyway, via TortoiseSVN in Windows you can just right click the lazarus folder and select "Create a patch"

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3654
  • I like bugs.
Re: Added patch to enable OnChange support for CDEdit and CDComboBox
« Reply #7 on: December 21, 2012, 08:16:50 pm »
You made a wrong command, it should be like this:

cd lazarus
svn diff > stab.patch

stab's command :
 svn diff lcl/customdrawncontrols.pas > stab.patch
is perfectly valid.
I guess he didn't have changes in customdrawncontrols.pas and thus the resulting file was empty.

Yes,  TortoiseSVN's "Create a patch" is maybe the best way for people who are not familiar with cmd line.

Juha