将下一个控件集中在覆盖的 KeyUp 中的 Enter - 上
我有一个扩展 TEdit 的自定义类:
TMyTextEdit = class (TEdit)
private
fFocusNextOnEnter: Boolean;
public
procedure KeyUp(var Key: Word; Shift :TShiftState); override;
published
property FocusNextOnExnter: Boolean read fFocusNextOnEnter
write fFocusNextOnEnter default false;
end;
在 KeyUp 过程中我这样做:
procedure TMyTextEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited;
if FocusNextOnExnter then
if Key = VK_RETURN then
SelectNext(Self as TWinControl, True, false);
end;
但它并没有将焦点转移到下一个控件。我尝试过,
if Key = VK_RETURN then
Key := VK_TAB;
但它也不起作用。我缺少什么?
I have my custom class that extends TEdit:
TMyTextEdit = class (TEdit)
private
fFocusNextOnEnter: Boolean;
public
procedure KeyUp(var Key: Word; Shift :TShiftState); override;
published
property FocusNextOnExnter: Boolean read fFocusNextOnEnter
write fFocusNextOnEnter default false;
end;
In The KeyUp procedure I do:
procedure TMyTextEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited;
if FocusNextOnExnter then
if Key = VK_RETURN then
SelectNext(Self as TWinControl, True, false);
end;
But it isn't moving focus to the next control. I tried to
if Key = VK_RETURN then
Key := VK_TAB;
but it isn't working either. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SelectNext
选择下一个同级子控件,即。您需要在编辑的父级上调用它:SelectNext
selects next sibling child control, ie. you need to call it on your edit's parent:这是记录的 PostMessage 方法(使用消息):)
Here's the PostMessage approach (uses Messages) for the record :)
THackWinControl 可以避免,并且让它变得更好:
问题是它仍然下拉组合框选项。
我正在努力。
The THackWinControl can be avoided, and to make it nice:
Problem is it still pull down combobox choices.
I'm working on that.