修改Delphi 10.1.2 edit控件在android的复制、剪切和粘贴样式
Delphi 10.1.2 edit控件在android默认的复制、剪切和粘贴样式太丑,经悟能-DelphiTeacher的提示,用最简单的代码修改后稍有改观。
默认的样式:

修改后的样式:

修改FMX.Platform.Android.pas
找到procedure TWindowManager.ShowContextMenu(const ItemsToShow: TContextMenuItems),按下面的红字增加Copy、cut和Paste button的setBackgroundColor属性。
FCopyButton.setBackgroundColor(TAlphaColors.Yellowgreen);//------增加这行,可以根据自己的喜好修改
FCutButton.setBackgroundColor(TAlphaColors.Yellowgreen);//------增加这行,可以根据自己的喜好修改
FPasteButton.setBackgroundColor(TAlphaColors.Yellowgreen);//------增加这行,可以根据自己的喜好修改
procedure TWindowManager.ShowContextMenu(const ItemsToShow: TContextMenuItems);
var
LA: TTextLayout;
P: TPoint;
HasSelection, HasClipboard: Boolean;
ApproxWidth: Integer;
ApproxHeight: Integer;
ClipboardValue: TValue;
ResID: Integer;
TextInput: ITextInput;
VirtualKeyboard: IVirtualKeyboardControl;
ClipboardSvc: IFMXClipboardService;
begin
DestroyPasteMenuTimer;
ApproxWidth := FContextMenuPopupSize.cx;
ApproxHeight := FContextMenuPopupSize.cy;
if not FContextMenuVisible and Supports(FFocusedControl, ITextInput, TextInput) and not FSelectionInProgress then
begin
FContextMenuVisible := True;
HasSelection := not TextInput.GetSelection.IsEmpty;
TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, ClipboardSvc);
ClipboardValue := ClipboardSvc.GetClipboard;
HasClipboard := not ClipboardValue.IsEmpty and not ClipboardValue.ToString.IsEmpty;
if FContextMenuPopup = nil then
begin
FContextMenuLayout := TJLinearLayout.JavaClass.init(TAndroidHelper.Activity);
FContextButtonsLayout := TJLinearLayout.JavaClass.init(TAndroidHelper.Activity);
LA := TTextLayoutManager.DefaultTextLayout.Create;
LA.Font.Style := LA.Font.Style + [TFontStyle.fsBold];
P := Point(0, 0);
Supports(FFocusedControl, IVirtualKeyboardControl, VirtualKeyboard);
if HasSelection then
begin
//Copy button
if (TContextMenuItem.Copy in ItemsToShow) and ((VirtualKeyboard = nil) or not VirtualKeyboard.IsPassword) then
begin
ResID := TAndroidHelper.GetResourceID('android:string/copy');
if ResID <> 0 then
LA.Text := TAndroidHelper.GetResourceString(ResID)
else
LA.Text := SEditCopy.ToUpper;
FCopyButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
if ResID <> 0 then
FCopyButton.setText(ResID)
else
FCopyButton.setText(StrToJCharSequence(LA.Text));
FCopyButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
FCopyButton.setBackgroundColor(TAlphaColors.Yellowgreen);//------增加这行,可以根据自己的喜好修改
FCopyClickListener := TCopyButtonClickListener.Create;
FCopyButton.setOnClickListener(FCopyClickListener);
LA.Font.Size := FCopyButton.getTextSize;
P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
ApproxHeight := P.Y + FCopyButton.getPaddingTop + FCopyButton.getPaddingBottom;
end;
//Cut button
if (TContextMenuItem.Cut in ItemsToShow) and not TextReadOnly and ((VirtualKeyboard = nil) or not VirtualKeyboard.IsPassword) then
begin
ResID := TAndroidHelper.GetResourceID('android:string/cut');
if ResID <> 0 then
LA.Text := TAndroidHelper.GetResourceString(ResID)
else
LA.Text := SEditCut.ToUpper;
FCutButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
if ResID <> 0 then
FCutButton.setText(ResID)
else
FCutButton.setText(StrToJCharSequence(LA.Text));
FCutButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
FCutButton.setBackgroundColor(TAlphaColors.Yellowgreen);//------增加这行,可以根据自己的喜好修改
FCutClickListener := TCutButtonClickListener.Create;
FCutButton.setOnClickListener(FCutClickListener);
LA.Font.Size := FCopyButton.getTextSize;
P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
end;
end;
if HasClipboard and (TContextMenuItem.Paste in ItemsToShow) and not TextReadOnly then
begin
//Paste button
ResID := TAndroidHelper.GetResourceID('android:string/paste');
if ResID <> 0 then
LA.Text := TAndroidHelper.GetResourceString(ResID)
else
LA.Text := SEditPaste.ToUpper;
FPasteButton := TJButton.JavaClass.init(TAndroidHelper.Activity);
if ResID <> 0 then
FPasteButton.setText(ResID)
else
FPasteButton.setText(StrToJCharSequence(LA.Text));
FPasteButton.setTypeface(TJTypeface.JavaClass.DEFAULT_BOLD);
FPasteButton.setBackgroundColor(TAlphaColors.Yellowgreen);//------增加这行,可以根据自己的喜好修改
FPasteClickListener := TPasteButtonClickListener.Create;
FPasteButton.setOnClickListener(FPasteClickListener);
LA.Font.Size := FPasteButton.getTextSize;
P.X := P.X + Ceil((LA.TextWidth + 2) * FScale);
P.Y := Max(P.Y, Ceil((LA.TextHeight + 2) * FScale));
if ApproxHeight = 0 then
ApproxHeight := P.Y + FPasteButton.getPaddingTop + FPasteButton.getPaddingBottom;
end;
修改Delphi 10.1.2 edit控件在android的复制、剪切和粘贴样式的更多相关文章
- Delphi 10 Seattle 小票打印控件TQ_Printer
TQ_Printrer控件,是一个为方便需要控制打印命令而设计的跨平台专用控件,已包含标准ESC/POS打印控制的基本指令在内(这些基本指令已能很好的满足多数项目使用). TQ_Printrer控件让 ...
- WPF的DataGrid控件从excel里复制数据然后粘贴
WPF的DataGrid控件不能像winform的DataGridView控件一样,支持值的粘贴.WPF的DataGrid控件本质上是跟数据绑定联系在一起,所以需要进行复制粘贴的操作,可以在wpf里用 ...
- win32 修改Edit控件文本颜色与背景色
#define WM_CTLCOLORMSGBOX 0x0132 #define WM_CTLCOLOREDIT 0x0133 //编辑控件Edit #define WM_CTLCOLORLISTBO ...
- delphi Components[i]清除所有edit控件中的内容
(* 一般的清空combobox方法 combobox1.clear; ... combobox9.clear; *) procedure TForm1.Button1Click(Sender: ...
- Delphi在Listview中加入Edit控件
原帖 : http://www.cnblogs.com/hssbsw/archive/2012/06/03/2533092.html Listview是一个非常有用的控件,我们常常将大量的数据(如数据 ...
- DELPHI 动态 创建和释放 多个 EDIT 控件
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, ...
- 增加duilib edit控件的提示功能和多种文字颜色
转载请说明原出处,谢谢~~:http://blog.csdn.net/zhuhongshu/article/details/41786407 duilib的CEditUI控件内部使用了win32的原生 ...
- Delphi下使用Oracle Access控件组下TOraSession控件链接
Delphi下使用Oracle Access控件组下TOraSession控件链接数据库,使用 orsn1.Options.Direct:=true; orsn1.Server:=IP:Port: ...
- emWin(ucGui) Edit控件数值模式 ——符号编辑 worldsing
emWin(ucGui) Edit控件数值模式出现负数值编辑时,如果键盘按键全可以设置独立的"-","+"键,这样可以正常编辑正数和负数,但是要没有设置这两个键 ...
随机推荐
- 美丽的Java图表类库
摘要 在使用java做后台站点的开发张,图表和报表功能都是不可或缺 的.本文推荐了8款最精彩实用的Java图表应用,大部分图表应用的功能都类似,主要在于界面的美观性和使用的灵活性上有一点高低. 正文 ...
- 基于MAC OS 操作系统安装、配置mysql
$ sudo mv mysql-5.1.45-osx10.6-x86_64 /usr/local/mysql$ cd /usr/local$ sudo chown -R mysql:mysql mys ...
- React核心内容归纳总结
状态.属性.组件API.组件的生命周期 当react的状态改变时,自动执行this.render()方法更新组件ES6写React的时候,事件里不会自动绑定this,需要自己绑定,或者直接在const ...
- Python学习--19 网络编程
TCP编程 Client 创建一个基于TCP连接的Socket: # coding: utf-8 import socket # 创建一个TCP连接: s = socket.socket(socket ...
- 论SNAPSHOT包的危害性
先介绍一下背景:我们应用是一个标准的spring+webx工程,博主在一次项目发布前为了再次测试一下自己的代码,将分支部署到日常环境中,但是项目启动的时候报错: 第一眼看到这个堆栈后有点懵逼 第一是上 ...
- 无限二等分[0,1]这个区间之后还剩下啥?what's left after dividing an unit interval [0,1] infinitely many times?
Dividing an unit interval \([0,1]\) into two equal subintervals by the midpoint \(\dfrac {0+1} {2}=\ ...
- IOS9.0 之后友盟分享详细过程
一: 申请友盟的AppKey(友盟的Key是根据应用的名称生成的!) 在友盟注册了你自己的开发者账号后就可以申请AppKey了.然后在这个方法里面设置Key - (BOOL)application:( ...
- Easy单例模式
在学习单例模式前,不妨问自己几个问题:单例模式是怎么来的,单例模式怎么去用? 单例模式是怎么来的? 这就从设计模式起源开始,他是在实际实践中遇到类似情况可以通用经验所得到的总结,一般在其他模块或者方法 ...
- vm虚拟机Kali2.0实现与物理机之间的文件拖动共享
MarkdownPad Document html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,ab ...
- SharePoint 2016 配置用户请求应用程序
最近看了看SharePoint的应用程序,觉得还是不错的,以前都没怎么注意过这样的功能.当然,应用程序除了让用户和管理员添加外,还可以让他们进行请求,把应用程序添加到应用程序目录,然后由统一的管理员进 ...