- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我用 Delphi 为平板电脑编写了一个小应用程序。所以没有键盘。应用程序中有一个小表单,用户可以在其中输入驱动程序名称。我想在表单上放置一个触摸键盘,但由于表单本身很小,无法容纳虚拟键盘。我可以把键盘的尺寸调小,但那样的话打字会很困难。所以我决定编写另一个仅由键盘组成的应用程序。当主应用程序中的 DBEdit 获得焦点时,我想执行 Touchkeyboard 应用程序,当 DBEdit 失去焦点时,我想关闭 Touchkeyboard 应用程序。我的问题之一是如何防止触摸键盘在启动时抢占焦点。另一个是我如何在主应用程序下显示触摸键盘。提前致谢。
最佳答案
您不需要其他应用程序。只需创建另一种形式,这样您就可以更好地处理焦点和隐藏。我不确定您所说的“就在”应用程序下方是什么意思,但我想您的意思是窗口的位置应该位于应用程序窗口下方。请参阅此片段:
有 2 种形式:MainForm 和 KeyboardForm。
unit MainFormUnit;
uses (...),KeyboardForm;
(...)
var KeybdShown: boolean = false;
procedure TMainForm.InputEditEnter(Sender: TObject); // OnEnter event
begin
if not KeybdShown then begin
KeybdShown:=true;
KeyboardForm.Top:=Top+ClientHeight;
KeyboardForm.Left:=Left;
KeyboardForm.ShowKeyboard(InputEdit); //Shows the keyboard form and sends our edit as parameter
end;
end;
procedure TMainForm.InputEditExit(Sender: TObject); // OnExit event
begin
KeyboardForm.Hide;
KeybdShown:=false;
end;
...
unit KeyboardFormUnit;
var FocusedControl: TObject;
implementation
uses MainFormUnit;
procedure TKeyboardForm.FormKeyPress(Sender: TObject; var Key: Char);
var VKRes: SmallInt;
VK: byte;
State: byte;
begin
VKRes:=VkKeyScanEx(Key, GetKeyboardLayout(0)); // Gets Virtual key-code for the Key
vk:=vkres; // The virtualkey is the lower-byte
State:=VKRes shr 8; // The state is the upper-byte
(FocusedControl as TEdit).SetFocus; // Sets focus to our edit
if (State and 1)=1 then keybd_event(VK_SHIFT,0,0,0); // These three procedures
if (State and 2)=2 then keybd_event(VK_CONTROL,0,0,0); // send special keys(Ctrl,alt,shift)
if (State and 4)=4 then keybd_event(VK_MENU,0,0,0); // if pressed
keybd_event(VK,0,0,0); // sending of the actual keyboard button
keybd_event(VK,0,2,0);
if (State and 1)=1 then keybd_event(VK_SHIFT,0,2,0);
if (State and 2)=2 then keybd_event(VK_CONTROL,0,2,0);
if (State and 4)=4 then keybd_event(VK_MENU,0,2,0);
Key:=#0;
end;
procedure TKeyboardForm.ShowKeybd(Focused: TObject);
begin
FocusedControl:=Focused;
Show;
end;
这基本上就是处理显示/隐藏表单所需的全部内容。由于 KeyboardForm 不会在启动时显示,因此它不会获得焦点(除非 Edit 将 TabOrder 设置为 0 并且 TabStop true - 然后 OnEnter 事件会在应用程序启动时触发)。
工作原理
注意:可以使用 SendInput() 代替 keybd_event。
关于delphi - 防止TouchKeyboard抢占焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6093046/
我写了一段代码,其中有一个数据: unsigned char buf[4096]; // data in chunks of size 4k unsigned counter[256]; 我将每 3
这个问题已经有答案了: Ajax too slow - Recursion (1 个回答) 已关闭 5 年前。 所以这件事在我脑海里思考了很长时间,是否 AJAx 中给出的计时器在它必须发送另一个请求
据我所知,在 Linux 中有许多机制可以实现 bottom-halves: 软中断 任务 工作队列 线程中断 ( request_threaded_irq() ) 它们在可调度性方面都有自己的特点。
根据这个问题here使用 pthread_spin_lock 锁定关键部分是危险的,因为线程可能会被调度程序中断,而其他线程可能会在该资源上保持旋转状态。 假设我决定从 pthread_spin_lo
从SLF4J页面我明白了这一点 The purpose of slf4j-log4j12 module is to delegate or redirect calls made to an SLF4
我在我的项目中使用了 xuggle library 将视频从 mp4 转码为 flv。我也使用 slf4j 库 来支持日志结束。 import com.xuggle.mediatool.IMediaR
我是一名优秀的程序员,十分优秀!