Cocoa-EventHandle

basic mouse event

mouse down, mouse dragging, mouse up, and mouse movement.

responder chain

view‘s next responder is its super view
generally a view insert into a view hierarchy ,this view is automatically as its subView’s next responder
never call setNextResponder method

firstResponder

如果一个view作为firstResponder 则这个view会先于其他对象接受到他们发送的消息的回应
通常表现比如文本框如果作为firstResponder就会有竖杠闪烁

general view only receive mouse-down message which is not as firstResponde,但是这个view必须显示在window上 并且是可见的
比如某个文本框并不是firstResponder,但是如果他被鼠标点击了 它就会作为firstResponder,所以它接受到了mouseDown

成为firstReponder

view.window makeFirstResponder:一个NSView或者NSTextField
//方法二
[NSTestField becomeFirstResponder];//不建议这样调用

element调用这个方法并不是一定生效,调用后首先会询问当前的first responder 让他resign,如果他同意了那会再查看一下目标element的canBecomeFirstResponder 如果可以然后会再查看这个element是否在active view hierarchy(如果element所属的window是一个valid window 则表示是在active view hierarchy) 这样才会将element置为first responder
这个responder cain的root 一般是application的key Window

一般是子类重写becomeFirstResponder方法里面添加对text filer的修饰 实现highlighting

acceptsFirstResponder

default NSResponder instance return NO
you can override this method

- (BOOL)acceptsFirstResponder
{
    return YES;
}

becomeFirstResponder

if a view receive this message ,is mean that window attemps to make the view first responder,default implementation this message return YES

resignFirstResponder

if you want to resign a view as firstResponder call this message

key view loop

key view loop let user can user press “tab” keys switch between views in a window
so if a view can become firstResponder ,this view must in key view loop
you can set a view as other view’s next key view by setting view’snextKeyView

target-action paradigm

控件向目标对象发送相应用户操作的操作信息 比如说一个按钮 单击该按钮会将操作消息发送到按钮的目标对象 如果未指定特定的目标对象 则会将其发送到响应者链的上游

获取鼠标点击的位置

通过locationInWindow获取鼠标点击在window的坐标,再通过convertPoint转换到view坐标系中

-(void)mouseDown:(NSEvent *)event
{
    NSPoint clickLocation;
	clickLocation = [self convertPoint:[event locationInWindow]
                  fromView:nil];
}

关于自己实现mouseMove这些message看这里

苹果开发文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
eclipse-jee-2023-03-r-macosx-cocoa-x86_64.dmg 是一个针对 macOS 系统的 Eclipse JEE 版本的安装文件。Eclipse 是一款开源的、跨平台的集成开发环境,为软件开发者提供了丰富的工具和功能,特别是针对 JavaEE 开发。 这个安装文件的版本号是 2023-03-r,意味着它是在2023年3月发布的第一个有重要改进的版本。macOSx-cocoa-x86_64 则表示这个程序适用于 macOS 操作系统的 cocoa 架构和 x86_64 位的处理器。.dmg 是 macOS 系统上常用的磁盘映像文件的扩展名。 通过安装这个文件,你可以在你的 macOS 系统上使用 Eclipse JEE 版本进行 JavaEE 的开发工作。它提供了一系列的插件和工具,包括代码编辑器、调试器、自动补全、版本控制等,以支持 JavaEE 技术的开发。你可以轻松地创建、编译、运行和调试 JavaEE 项目,并且可以方便地导入和管理项目。 Eclipse JEE 版本还针对 JavaEE 开发提供了额外的功能和集成,比如支持服务器的管理和部署、Web 服务的开发和测试、数据源的管理等。你可以通过插件来进一步扩展它的功能,以满足你对开发环境的特殊需求。 总而言之,eclipse-jee-2023-03-r-macosx-cocoa-x86_64.dmg 是一款适用于 macOS 系统的 Eclipse JEE 开发环境的安装文件。安装后,你可以利用它进行 JavaEE 技术的开发,包括创建、编辑、运行和调试项目,并享受一系列丰富的功能和插件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值