text控件:新增光标后插入;新增可控边界

This commit is contained in:
睿 安
2026-01-27 14:45:32 +08:00
parent 1be1ecbbf2
commit 9fe2fe5874
29 changed files with 255 additions and 114 deletions

View File

@@ -39,12 +39,17 @@ namespace ezui {
std::wstring m_placeholder;//placeholder懂得都懂 (在没有文字的情况下显示的文字)
std::wstring m_passwordChar;
bool m_readOnly = false;//是否只读
// 内边距(四边独立)
int m_padLeft = 6;
int m_padTop = 4;
int m_padRight = 6;
int m_padBottom = 4;
public:
//文字对其方式(针对单行输入框有效)
TextAlign TextAlign = TextAlign::MiddleLeft;
private:
void Init();
void InsertUnicode(const std::wstring& str);//插入unicode文字内部使用
void InsertUnicode(const std::wstring& str, bool isEnd = false);//插入unicode文字内部使用
bool DeleteRange();//删除选中内容
bool GetSelectedRange(int* outPos, int* outCount);//获取当前被选中的区域 返回下标和个数
bool Copy();//复制到剪切板
@@ -69,18 +74,24 @@ namespace ezui {
virtual void OnKillFocus(const KillFocusEventArgs& arg) override;
virtual void OnLayout();
void Offset(int moveY);
// 支持 TextBox 自身扩展样式属性padding 系列)
virtual bool ApplyStyleProperty(const UIString& key, const UIString& value) override;
public:
std::function<void(const UIString&)> TextChanged = NULL;
public:
TextBox(Object* parentObject = NULL);
virtual ~TextBox();
// 设置内边距 (兼容旧接口:水平=px, 垂直=py)
void SetPadding(int px, int py);
// 设置四边
void SetPadding4(int left, int top, int right, int bottom);
virtual void SetAttribute(const UIString& key, const UIString& value)override;
//获取焦点所在光标位置
virtual Rect GetCareRect()override;
//分析字符串
void Analysis();
//在当前光标中插入文字
void Insert(const UIString& str);
void Insert(const UIString& str, bool isEnd = false);
//获取输入框文字
const UIString GetText();
//获取滚动条