I am attempting to construct a self-contained MVP control called Catalog;
the model named Catalog, the view named CatalogView, and the presenter named CatalogPresenter. I added a context menu to the Catalog View in the View editor and created command handler methods in the CatalogView class. When I test this control, the menus are properly enabled. Next I created a second MVP control called CatalogShell; the model named CatalogShell, the view named CatalogShellView, and the presenter named CatalogShellPresenter. The CatalogShell control should contain an instance of the Catalog control and additionally provides a toolbar and menu bar for the program. When I test the CatalogShell control, I noticed that the context menu items in the Catalog control are now disabled. Upon further inspection, if I add command handler methods named identical to the CatalogView class's handler methods, the menu items become reenabled. Is the default behavior of the context menus to be handled by the top-most view? Does anybody know how to construct an MVP control such that no matter which parent view the control is placed in, the context menu messages are sent to the original control? (i.e. I would like the context menu handlers for the Catalog control to be sent to the class CatalogView, not CatalogShellView). Jon |
Jonathon Spaeth <[hidden email]> wrote in message
news:Ca8f9.10124$[hidden email]... ... > Is the default behavior of the context menus to be handled by the top-most > view? Does anybody know how to construct an MVP control such that no matter > which parent view the control is placed in, the context menu messages are > sent to the original control? (i.e. I would like the context menu handlers > for the Catalog control to be sent to the class CatalogView, not > CatalogShellView). If I understand what you are describing correctly the context menus should be handled by the CatalogPresenter, and should be enabled if the methods exist. The problem you are experiencing sounds like the view may not be properly connected to the presenter. You might double check your creatPresenters method, and make sure the view name and the name used in the code there are the same. Also make sure your onViewOpened method does a super send. You might try using the visual inspector or some well placed halts to make sure the presenters are what they are supposed to be. I think this should work the way you expect it to work, rather then the way it appears to be working. Chris |
Chris
Thanks for the reply; my view and presenter were properly connected; the problem, however, was that I implemented the message handlers in the CatalogView class as opposed to the CatalogPresenter. When I moved those methods from the view class to the presenter class, the weird behavior disappeared. Thanks for the help! Jon "Christopher J. Demers" <[hidden email]> wrote in message news:alj8gs$1r8dob$[hidden email]... > Jonathon Spaeth <[hidden email]> wrote in message > news:Ca8f9.10124$[hidden email]... > ... > > Is the default behavior of the context menus to be handled by the top-most > > view? Does anybody know how to construct an MVP control such that no > matter > > which parent view the control is placed in, the context menu messages are > > sent to the original control? (i.e. I would like the context menu > handlers > > for the Catalog control to be sent to the class CatalogView, not > > CatalogShellView). > > If I understand what you are describing correctly the context menus should > be handled by the CatalogPresenter, and should be enabled if the methods > exist. The problem you are experiencing sounds like the view may not be > properly connected to the presenter. You might double check your > creatPresenters method, and make sure the view name and the name used in > code there are the same. Also make sure your onViewOpened method does a > super send. You might try using the visual inspector or some well placed > halts to make sure the presenters are what they are supposed to be. I think > this should work the way you expect it to work, rather then the way it > appears to be working. > > Chris > > |
Free forum by Nabble | Edit this page |