提交 b98b0d90 编写于 作者: C cz_012273

修改记事本横屏界面(分别设计横竖屏布局),处理虚拟键盘打开时旋转屏幕出错的问题(用close命令退出虚拟键盘编辑状态)。

上级 09a81f8f
......@@ -194,7 +194,7 @@ end;
procedure TToolsForm.ComboBox1ClosePopup(Sender: TObject);
begin
ComboBox1.resetfocus;
ComboBox1.resetfocus; //ComboBox1失去焦点
end;
procedure TToolsForm.DisplayRationale(Sender: TObject;
......
......@@ -346,23 +346,23 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_24x24.png" Configuration="Debug" Class="Android_NotificationIcon24">
<DeployFile LocalName="Android64\Debug\colors.xml" Configuration="Debug" Class="Android_Colors">
<Platform Name="Android64">
<RemoteName>ic_notification.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Android64\Debug\AndroidManifest.xml" Configuration="Debug" Class="ProjectAndroidManifest">
<DeployFile LocalName="Android64\Debug\styles.xml" Configuration="Debug" Class="AndroidSplashStyles">
<Platform Name="Android64">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Android64\Debug\colors.xml" Configuration="Debug" Class="Android_Colors">
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_24x24.png" Configuration="Debug" Class="Android_NotificationIcon24">
<Platform Name="Android64">
<RemoteName>ic_notification.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Android64\Debug\styles.xml" Configuration="Debug" Class="AndroidSplashStyles">
<DeployFile LocalName="Android64\Debug\AndroidManifest.xml" Configuration="Debug" Class="ProjectAndroidManifest">
<Platform Name="Android64">
<Overwrite>true</Overwrite>
</Platform>
......
......@@ -2,6 +2,7 @@ inherited Form1_LgXhdpiPh: TForm1_LgXhdpiPh
ClientHeight = 720
ClientWidth = 450
FormFactor.Height = 720
OnResize = DoOrientationChanged
OnShow = Formshow
DesignerMasterStyle = 3
inherited Image1: TImage
......@@ -19,37 +20,44 @@ inherited Form1_LgXhdpiPh: TForm1_LgXhdpiPh
Viewport.Height = 498.000000000000000000
end
inherited Button1: TButton
Anchors = [akTop]
StyledSettings = [Family, Size, Style]
Position.X = 371.000000000000000000
Size.Width = 80.000000000000000000
TextSettings.FontColor = claDarkgreen
end
inherited Filedelete: TButton
Anchors = []
Position.X = 6.000000000000000000
Position.Y = 665.000000000000000000
Size.Width = 165.000000000000000000
end
inherited FileExit: TButton
Anchors = []
Position.X = 278.000000000000000000
Position.Y = 665.000000000000000000
Size.Width = 165.000000000000000000
end
inherited FileNew: TButton
Anchors = []
Position.X = 6.000000000000000000
Position.Y = 537.000000000000000000
Size.Width = 165.000000000000000000
end
inherited FileOpen: TButton
Anchors = []
Position.X = 278.000000000000000000
Position.Y = 537.000000000000000000
Size.Width = 165.000000000000000000
end
inherited FileSave: TButton
Anchors = []
Position.X = 6.000000000000000000
Position.Y = 601.000000000000000000
Size.Width = 165.000000000000000000
end
inherited FileSaveAs: TButton
Anchors = []
Position.X = 278.000000000000000000
Position.Y = 601.000000000000000000
Size.Width = 165.000000000000000000
......
......@@ -4,7 +4,7 @@ interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
System.Variants,FMX.VirtualKeyboard,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.Layouts, FMX.StdCtrls,
System.IOUtils, FMX.Objects, FMX.Ani, FMX.Effects, System.DateUtils, Posix.Unistd;
......@@ -36,6 +36,7 @@ type
procedure FiledeleteMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure Memo1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
procedure DoOrientationChanged(Sender: TObject);
private
{ Private declarations }
......@@ -65,7 +66,7 @@ implementation
uses
{$IFDEF ANDROID}
{$ENDIF}
MyDialogs;
MyDialogs,FMX.Platform;
type
TTextFormat = (tfAnsi, tfUnicode, tfUnicodeBigEndian, tfUtf8);
......@@ -74,6 +75,8 @@ var
today: Cardinal;
selstart: integer;
sellength: integer;
screenstate:integer;
const
// TextFormatFlag: array[tfAnsi..tfUtf8] of word=($0000,$FFFE,$FEFF,$EFBB);
......@@ -81,8 +84,10 @@ const
$BBEF); // 编码标志高低字节互换
{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}
resourcestring
sSaveChanges = '是否将未更改保存到 %s?';
sOverWrite = '%s 已存在。' + #13#10 + '要替换它吗?';
......@@ -91,6 +96,85 @@ resourcestring
sColRowInfo = 'Line: %3d Col: %3d';
sCommonDlgFileName = '文本文档(*.txt)|*.txt|所有文件(*.*)|*.*';
procedure TForm1.DoOrientationChanged(Sender: TObject);
var
screenService: IFMXScreenService;
Keyboard: IFMXVirtualKeyboardService;
begin
if Assigned(Label_A) and Assigned(Button_A) then
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXVirtualKeyboardService,Keyboard) then
begin
if TVirtualKeyBoardState.Visible in Keyboard.GetVirtualKeyBoardState then
begin
Keyboard.HideVirtualKeyboard; //关闭虚拟键盘
end
end;
Close; //使编辑框失去焦点
Label_A.visible:=false;
Label_B.visible:=false;
Button_A.visible:=false;
Button_B.visible:=false;
end;
if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, screenService) then begin
case screenService.GetScreenOrientation of
TScreenOrientation.Portrait: //竖屏状态
begin
screenstate:=1;
memo1.height:=480;
memo1.width:=344;
button1.position.x:=275;
filenew.position.x:=6;filenew.position.y:=527;
filesave.position.x:=6;filesave.position.y:=591;
filedelete.position.x:=6;filedelete.position.y:=655;
fileopen.position.x:=188;fileopen.position.y:=527;
filesaveas.position.x:=188;filesaveas.position.y:=591;
fileexit.position.x:=188;fileexit.position.y:=655;
end;
TScreenOrientation.Landscape: //横屏状态
begin
screenstate:=2;
memo1.height:=328;
memo1.width:=532;
button1.position.x:=463;
filenew.position.x:=555;filenew.position.y:=10;
filesave.position.x:=555;filesave.position.y:=70;
filedelete.position.x:=555;filedelete.position.y:=130;
fileopen.position.x:=555;fileopen.position.y:=190;
filesaveas.position.x:=555;filesaveas.position.y:=250;
fileexit.position.x:=555;fileexit.position.y:=310;
end;
TScreenOrientation.InvertedPortrait: //倒竖屏状态
begin
screenstate:=3;
memo1.height:=480;
memo1.width:=344;
button1.position.x:=275;
filenew.position.x:=6;filenew.position.y:=527;
filesave.position.x:=6;filesave.position.y:=591;
filedelete.position.x:=6;filedelete.position.y:=655;
fileopen.position.x:=188;fileopen.position.y:=527;
filesaveas.position.x:=188;filesaveas.position.y:=591;
fileexit.position.x:=188;fileexit.position.y:=655;
end;
TScreenOrientation.InvertedLandscape: //倒横屏状态
begin
screenstate:=4;
memo1.height:=328;
memo1.width:=532;
button1.position.x:=463;
filenew.position.x:=555;filenew.position.y:=10;
filesave.position.x:=555;filesave.position.y:=70;
filedelete.position.x:=555;filedelete.position.y:=130;
fileopen.position.x:=555;fileopen.position.y:=190;
filesaveas.position.x:=555;filesaveas.position.y:=250;
fileexit.position.x:=555;fileexit.position.y:=310;
end;
end;
end;
end;
procedure TForm1.SetFileName(const FileName: String);
begin
FFileName := System.IOUtils.Tpath.GetSharedDocumentsPath + '/' +
......@@ -259,7 +343,7 @@ begin
Label_B.free;
Button_A.free;
Button_B.free;
Memo1.height := 510; // 将meno控件恢复到默认高度
Memo1.height := 480; // 将meno控件恢复到默认高度
Memo1.Lines.clear;
end;
FWantExit := True;
......@@ -289,20 +373,24 @@ end;
procedure TForm1.Memo1MouseLeave(Sender: TObject); // 改变memo1高度以适应虚拟键盘
var
i: integer;
const
halfscreen :integer = 403; //显示输入法界面后的memo高度
halfscreen :integer; //显示输入法界面后的memo高度
begin
i := Memo1.selstart;
// showmessage(inttostr(i));
if (i>0) and (Memo1.height > 430) then
if (screenstate=2)or(screenstate=4) then
halfscreen := 298
else
halfscreen := 403;
if (i>0) and (Memo1.height > halfscreen) then
begin
Memo1.height := halfscreen;
Memo1.selstart := i;
//创建显示行、列号标签
Label_A := tlabel.Create(Self);
if not Assigned(Label_A) then Label_A := tlabel.Create(Self);
with Label_A do
begin
Parent := Self;
......@@ -314,7 +402,7 @@ begin
Visible := true;
end;
Label_B := tlabel.Create(Self);
if not Assigned(Label_B) then Label_B := tlabel.Create(Self);
with Label_B do
begin
Parent := Self;
......@@ -328,7 +416,7 @@ begin
//创建滚动条加速按钮
Button_A := tButton.Create(Self);
if not Assigned(Button_A) then Button_A := tButton.Create(Self);
with Button_A do
begin
Parent := Self;
......@@ -341,7 +429,7 @@ begin
onclick := Button_A_Click; //设置点击事件
end;
Button_B := tButton.Create(Self);
if not Assigned(Button_B) then Button_B := tButton.Create(Self);
with Button_B do
begin
Parent := Self;
......@@ -356,7 +444,7 @@ begin
end;
if Memo1.height = halfscreen then //动态更新行列号
if (Memo1.height = halfscreen) and (Assigned(Label_A)) then //动态更新行列号
begin
Label_A.Text := '当前行号:'+IntToStr(Memo1.CaretPosition.line+1);
Label_B.Text := '当前列号:'+IntToStr(Memo1.CaretPosition.Pos+1);
......
......@@ -32280,6 +32280,7 @@ inherited ToolsForm_LgXhdpiPh: TToolsForm_LgXhdpiPh
end
inherited Panel1: TPanel
Position.X = 16.000000000000000000
Size.Width = 330.000000000000000000
Size.Height = 305.000000000000000000
inherited Label1: TLabel
StyledSettings = [Family, Style, FontColor]
......@@ -32294,7 +32295,7 @@ inherited ToolsForm_LgXhdpiPh: TToolsForm_LgXhdpiPh
inherited Label3: TLabel
StyledSettings = [Family, Style, FontColor]
Position.X = 7.000000000000000000
Position.Y = 180.000000000000000000
Position.Y = 170.000000000000000000
Size.Width = 50.000000000000000000
Size.Height = 25.000000000000000000
Text = #25628#32034
......@@ -32302,7 +32303,7 @@ inherited ToolsForm_LgXhdpiPh: TToolsForm_LgXhdpiPh
inherited Label2: TLabel
StyledSettings = [Family, Style, FontColor]
Position.X = 7.000000000000000000
Position.Y = 102.000000000000000000
Position.Y = 97.000000000000000000
Size.Width = 50.000000000000000000
Size.Height = 25.000000000000000000
TextSettings.Font.Size = 24.000000000000000000
......@@ -32310,13 +32311,13 @@ inherited ToolsForm_LgXhdpiPh: TToolsForm_LgXhdpiPh
end
inherited Edit2: TEdit
Position.X = 72.000000000000000000
Position.Y = 175.000000000000000000
Position.Y = 165.000000000000000000
Size.Width = 250.000000000000000000
end
inherited Edit1: TEdit
Text = 'www.baidu.com'
Position.X = 72.000000000000000000
Position.Y = 97.000000000000000000
Position.Y = 92.000000000000000000
Size.Width = 250.000000000000000000
end
inherited ComboBox1: TComboBox
......@@ -32329,12 +32330,12 @@ inherited ToolsForm_LgXhdpiPh: TToolsForm_LgXhdpiPh
inherited SpeedButton1: TSpeedButton
AutoTranslate = False
Position.X = 24.000000000000000000
Position.Y = 250.000000000000000000
Position.Y = 240.000000000000000000
OnClick = SpeedButton1Click
end
inherited SpeedButton2: TSpeedButton
Position.X = 200.000000000000000000
Position.Y = 250.000000000000000000
Position.X = 202.000000000000000000
Position.Y = 240.000000000000000000
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册