How to create “No Activate” form in Firemonkey

后端 未结 2 1422
温柔的废话
温柔的废话 2021-01-30 11:56

In XCode by adding these methods to your NSView subclass can prevent the window from becoming active when clicking on it:

-         


        
2条回答
  •  臣服心动
    2021-01-30 12:34

    You can turn off the forms mouse handling to prevent it being focused. Assuming your form is called myform:

    uses fmx.platform.mac, macapi.appkit;
    .
    .
    Var nswin:nswindow;
    .
    .  
    NSWin:= NSWindow(NSWindowFromObjC(FmxHandleToObjC(myform.Handle))); { get the NSWindow }
    NSWin.setIgnoresMouseEvents(true);                                 { ignore mouse events }
    NSWin.setAcceptsMouseMovedEvents(false);
    

    There is a slight problem in that it doesn't stop a right mouse click. If that's a problem, you will have to respond to the mousedown event in the form and call the main forms mousedown so it doesn't lose the mouse event. Since the right mouse down will then capture the mouse events, you also then need to respond to mouse move and mouse up events too - forwarding them to your main form. Although it captures the mouse on right click, it will still not focus the form.

    Dave Peters DP Software

提交回复
热议问题