FAQ
I noticed that the Cocoa implementation of GUI.EditCmdHandler uses the
NSMenuValidation protocol to figure out whether each of the Edit menu
commands should be enabled. But the WebView class (in WebKit) doesn't
implement this protocol. So can anyone figure out how WebKit indicates
the current validity of Edit menu commands? I know it does, somehow,
because I've written a native Cocoa app that uses WebKit, and without me
paying any attention to enabling and disabling menu items, it just works
as expected.

Matt

Search Discussions

  • Matt Campbell at Jan 22, 2012 at 3:52 pm
    I just found the answer to my own question. The solution is to call
    'validateUserInterfaceItem:'.

    I wonder, though, if PyGUI needs to be more hands-off here. As I
    mentioned in my previous post, it appears that Cocoa automatically takes
    care of enabling and disabling standard menu items, such as those on the
    Edit menu.

    Matt
  • Greg Ewing at Jan 22, 2012 at 9:36 pm

    Matt Campbell wrote:
    I just found the answer to my own question. The solution is to call
    'validateUserInterfaceItem:'.

    I wonder, though, if PyGUI needs to be more hands-off here. As I
    mentioned in my previous post, it appears that Cocoa automatically takes
    care of enabling and disabling standard menu items, such as those on the
    Edit menu.
    The problem is that PyGUI has its own way of handling the
    enabling of menu items, and somehow this needs to be made to
    dovetail with what Cocoa does.

    For example, the user should be able to create a subclass of
    TextField and override its setup_menus() method to modify the
    conditions for enabling edit commands.

    The only way I can think of to make that possible is to
    intercept Cocoa's attempts to find out which commands to
    enable, funnel them through the setup_menus mechanism, and
    then call the appropriate underlying Cocoa methods from
    the setup_menus methods.

    --
    Greg

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppygui @
categoriespython
postedJan 22, '12 at 2:08a
activeJan 22, '12 at 9:36p
posts3
users2
websitecosc.canterbury.ac.nz...

2 users in discussion

Matt Campbell: 2 posts Greg Ewing: 1 post

People

Translate

site design / logo © 2019 Grokbase