LCL: fixed TComboBox.SelText (bug #8450) based on patch by Tom

git-svn-id: trunk@10848 -
This commit is contained in:
vincents 2007-04-02 09:45:39 +00:00
parent 31606f9a53
commit c094754b4c
8 changed files with 203 additions and 3 deletions

6
.gitattributes vendored
View File

@ -2916,6 +2916,12 @@ test/bugs/8437/project1.lpr svneol=native#text/pascal
test/bugs/8437/unit1.lfm svneol=native#text/plain
test/bugs/8437/unit1.lrs svneol=native#text/pascal
test/bugs/8437/unit1.pas svneol=native#text/pascal
test/bugs/8450/expected.txt svneol=native#text/plain
test/bugs/8450/project1.lpi svneol=native#text/plain
test/bugs/8450/project1.lpr svneol=native#text/plain
test/bugs/8450/unit1.lfm svneol=native#text/plain
test/bugs/8450/unit1.lrs svneol=native#text/plain
test/bugs/8450/unit1.pas svneol=native#text/plain
test/bugs/bug8432.pas svneol=native#text/plain
test/bugs/testfileutil.pas svneol=native#text/plain
test/bugtestcase.pas svneol=native#text/plain

View File

@ -259,7 +259,7 @@ function TCustomComboBox.GetSelText: string;
begin
//debugln('TCustomComboBox.GetSelText ');
if FStyle in [csDropDown, csSimple] then
Result:= Copy(Text, SelStart, SelLength)
Result:= Copy(Text, SelStart + 1, SelLength)
else
Result:= '';
end;
@ -274,13 +274,17 @@ end;
procedure TCustomComboBox.SetSelText(const Val: string);
var
OldText, NewText: string;
OldSelStart: integer;
begin
//debugln('TCustomComboBox.SetSelText ',Val);
if FStyle in [csDropDown, csSimple] then begin
OldText:=Text;
NewText:=LeftStr(OldText,SelStart-1)+Val
+RightStr(OldText,length(OldText)-SelStart-SelLength+1);
OldSelStart:=SelStart;
NewText:=LeftStr(OldText,OldSelStart)+Val
+RightStr(OldText,length(OldText)-SelStart-SelLength);
Text:=NewText;
SelStart:=OldSelStart;
SelLength:=length(Val);
end;
end;

View File

@ -0,0 +1,3 @@
ComboBox SelText: boB
ComboBox.Text: Com1234ox1
ComboBox.SelText: 1234

View File

@ -0,0 +1,70 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="5"/>
<General>
<SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<ComponentName Value="Form1"/>
<IsPartOfProject Value="True"/>
<ResourceFilename Value="unit1.lrs"/>
<UnitName Value="Unit1"/>
</Unit1>
<Unit2>
<Filename Value="expected.txt"/>
<IsPartOfProject Value="True"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Linking>
<Debugging>
<UseLineInfoUnit Value="False"/>
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
</Linking>
<Other>
<CustomOptions Value="-Faheaptrc
"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,18 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms
{ add your units here }, Unit1;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

30
test/bugs/8450/unit1.lfm Normal file
View File

@ -0,0 +1,30 @@
object Form1: TForm1
Left = 290
Height = 50
Top = 159
Width = 212
HorzScrollBar.Page = 211
VertScrollBar.Page = 49
Caption = 'Form1'
object ComboBox1: TComboBox
Left = 32
Height = 21
Top = 8
Width = 100
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
MaxLength = 0
TabOrder = 0
Text = 'ComboBox1'
end
object ApplicationProperties1: TApplicationProperties
CaptureExceptions = True
HintColor = clInfoBk
HintHidePause = 2500
HintPause = 500
HintShortCuts = True
ShowHint = True
OnIdle = ApplicationProperties1Idle
left = 156
top = 9
end
end

13
test/bugs/8450/unit1.lrs Normal file
View File

@ -0,0 +1,13 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'"'#1#6'Height'#2'2'#3'Top'#3#159#0#5'Widt'
+'h'#3#212#0#18'HorzScrollBar.Page'#3#211#0#18'VertScrollBar.Page'#2'1'#7'Cap'
+'tion'#6#5'Form1'#0#9'TComboBox'#9'ComboBox1'#4'Left'#2' '#6'Height'#2#21#3
+'Top'#2#8#5'Width'#2'd'#16'AutoCompleteText'#11#22'cbactEndOfLineComplete'#20
+'cbactSearchAscending'#0#9'MaxLength'#2#0#8'TabOrder'#2#0#4'Text'#6#9'ComboB'
+'ox1'#0#0#22'TApplicationProperties'#22'ApplicationProperties1'#17'CaptureEx'
+'ceptions'#9#9'HintColor'#7#8'clInfoBk'#13'HintHidePause'#3#196#9#9'HintPaus'
+'e'#3#244#1#13'HintShortCuts'#9#8'ShowHint'#9#6'OnIdle'#7#26'ApplicationProp'
+'erties1Idle'#4'left'#3#156#0#3'top'#2#9#0#0#0
]);

56
test/bugs/8450/unit1.pas Normal file
View File

@ -0,0 +1,56 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
ApplicationProperties1: TApplicationProperties;
ComboBox1: TComboBox;
procedure ApplicationProperties1Idle(Sender: TObject; var Done: Boolean);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
var
InTestRun: boolean;
{ TForm1 }
procedure TForm1.ApplicationProperties1Idle(Sender: TObject; var Done: Boolean);
begin
ComboBox1.SelStart := 3;
ComboBox1.SelLength := 3;
if InTestRun then
writeln('ComboBox SelText: ', ComboBox1.SelText);
ComboBox1.SelText := '1234';
if InTestRun then begin
writeln('ComboBox.Text: ', ComboBox1.Text);
writeln('ComboBox.SelText: ', ComboBox1.SelText);
Close;
end;
ApplicationProperties1.OnIdle := nil;
end;
initialization
{$I unit1.lrs}
InTestRun := paramstr(1)='--runtest';
end.