点击 MAC 浮动窗口中的按钮后,将焦点返回到编辑器 [英] Return focus to Editor after clicking a button in floating window of MAC

查看:30
本文介绍了点击 MAC 浮动窗口中的按钮后,将焦点返回到编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 adobe flex 中创建了一个虚拟键盘库.

I have created a virtual keyboard library in adobe flex.

我已经为 Windows 创建了一个 ANE,以将键盘设置为始终在顶部且不可聚焦.使用:

I have already created an ANE for Windows to set the keyboad always on top and non focusable. Using:

int exstyle = GetWindowLong(hwnd3, GWL_EXSTYLE);
exstyle |= WS_EX_NOACTIVATE; 

但现在我必须为 mac (OS 10.7) 创建一个 ANE

But now I have to create an ANE for the mac (OS 10.7)

  1. 我必须从正在运行的 flex 应用程序访问键盘 (keywindow)
  2. 将其设置为始终在顶部且不可聚焦(即使我单击按键或从键盘的组合框中选择键盘语言,它也不会聚焦).这样光标将始终停留在编辑器中.

<小时>

我已经使用


I have tested a sample mac application (for testing purpose only) by using

setLevel:NSFloatingWindowLevel 

但是,当我单击窗口的空白区域时,它没有获得焦点(光标停留在我的编辑器/文本区域中),但是当我单击其上的任何按钮时,该按钮会获得焦点.

However when I click on the blank area of the window it is not getting focused (cursor stays in my editor/textarea), but when I click on any button on it that button get focused.

如何在 Mac 中访问 flex 虚拟键盘并将其设置为无激活模式

How to access the flex virtual keyboard and set it to No-Activate mode in Mac

------------------------------添加--------------------------------------------------------

------------------------------ADDED--------------------------------------------------------

我使用此代码将我的 Flex 应用程序设置在所有窗口 NSWindow 的顶部

I have used this code to set my Flex application at top of all windows NSWindow

*myMainWindow = [[[NSApplication sharedApplication] windows] objectAtIndex:0];
//[myMainWindow setLevel:NSFloatingWindowLevel]; 
[myMainWindow setLevel:NSMainMenuWindowLevel+1]; 

但我想停用那个窗口,这样它就不会被聚焦.就像 mac 中的 KeyboardViewer.每次单击键(Flex 键盘)时,应将 KeyEvent 重定向到当前的 TextInput.

But I want to deactivate that window so that it won't get focused. like KeyboardViewer in mac. The KeyEvent should be redirected to the current TextInput for every click of the key(Flex Keyboard).

请帮助我提出您的建议.

Please help me with your suggestions.

推荐答案

您是说您在尝试转换窗口的键盘应用程序中创建了 ANE?除非您可以将 flex 应用程序配置为将其主窗口创建为 NSPanel 而不是 NSWindow,否则 ANE 似乎是可行的方法.

Are you saying you created an ANE in the keyboard app that is trying to convert the Window? An ANE seems to be the way to go unless you can configure the flex application to create its main window as an NSPanel instead of an NSWindow.

您可以做的是创建一个与窗口大小相同的面板,然后将面板的内容视图设置为窗口的内容视图.这会将所有窗口的内容移动到您新创建的面板.然后在主窗口上调用 orderOut 并在面板上调用 makeKeyAndOrderFront.这是我们在 Connect 中的类似代码:

What you can do is create a panel the same size as the window then set the panel's content view to the window's content view. That will move all the window's contents to your newly created panel. Then call orderOut on the main window and makeKeyAndOrderFront on the panel. Here is similar code we had in Connect:

NSWindow *mainWindow = [[NSApp windows] objectAtIndex: 0];
NSView *mainContentView = [mainWindow contentView];

NSPanel *mainPanel = [[NSPanel alloc] initWithContentRect:[mainContentView frame]
                 styleMask:NSBorderlessWindowMask | NSNonactivatingPanelMask
                backing:NSBackingStoreBuffered defer:YES];

[mainPanel setContentView:mainContentView];
[mainPanel setLevel:NSScreenSaverWindowLevel];

[mainPanel makeKeyAndOrderFront:nil];
[mainContentView orderOut:nil];

这篇关于点击 MAC 浮动窗口中的按钮后,将焦点返回到编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆