sonorius
|
Posted: August 13, 2009 12:53 by sonorius
|
|
Hello, I was trying the third option (nested controllers) of David's reply in http://groups.google.com/group/monkeybars/browse_thread/thread/6f0c5e59110b696b and it works, except that the handlers don't seem to be called. No time to explain more details at the moment, it's just that nothing happens when the Button is clicked. Thanks for looking into it. Sven |
define_handler for JDialog
by: sundbp
Logan Barnett
|
Posted: August 13, 2009 18:53 by Logan Barnett
|
|
If your handlers aren't set up, look at the name used in View.nest and in your Controller#addnestedcontroller. These names must match, and Monkeybars doesn't convert Symbols to Strings automatically. |
sonorius
|
Posted: August 13, 2009 21:18 by sonorius
|
|
Hello Logan, well, I have tried to do everything according to the already mentioned Post of David. So, I'll just post the code of my little example application:
haupt_controller.rb:
And the symptom I get is that everything works normal,
except that clicking on Thank you for your help Sven |
sonorius
|
Posted: August 14, 2009 14:29 by sonorius
|
|
And, for easier reading, this code as a pastie: http://pastie.org/584045 Sven |
Logan Barnett
|
Posted: August 14, 2009 18:31 by Logan Barnett
|
|
Sven, :window_close is going to need some more work. See add_listener in the rdoc (it has a sample near the bottom): http://monkeybars.rubyforge.org/api/classes/Monkeybars/EventHandlerRegistrationAndDispatchMixin/ClassMethods.src/M000012.html define_handler piggybacks the implicit handler registration that lets you make an ok_button_action_performed method that just works. However, we don't raise an error anytime a method is created that looks funny, or writing your controller would become a pain. This means we get silent failure. Perhaps we can abuse blocks in a future version where you can set up implicit handlers, and raise anything that doesn't match.
Back to your problem though. Can you create vanilla handlers in your nested controller and see if you get output for them? Then we can look at making them fancy and working with define_handler. Make sure your button name matches what your handler thinks it is (: |
sonorius
|
Posted: August 14, 2009 19:56 by sonorius
|
|
Hello Logan, I have not yet examined everything I could or wanted to, Your suggestion to first try vanilla handlers proved to be very useful.
At first I thought: Ouch, it was a typo after all! I tried to reduce the example, removed the main component And then, trying to make the example even more vanilla, I only realised afterwards that I had forgotten to comment out Anything you can say about these findings? Regards Sven |
sonorius
|
Posted: August 14, 2009 20:33 by sonorius
|
|
Hi again, I think it helps imagine what I was talking about, if I post some code:
|
Logan Barnett
|
Posted: August 14, 2009 22:56 by Logan Barnett
|
|
Interesting find! I'm not sure how we can reliably detect when you use both set_java_class AND override create_main_view_component without using some real black magic. When using set_java_class, the create_main_view_component does get used, but in the case of a pure Ruby or manual constructor invocation, you can override create_main_view_component. I'm open to suggestions, but I'd hate to make this stuff order-dependent at the class level. |
sundbp
|
Posted: December 16, 2009 12:23 by sundbp
|
|
I'll put some info on this thread as well (followd up on another dialog thread yesterday). I'm trying something similar to this thread: dialog view:
enddialog controller:
endin main controller: def tradetablekey_pressed(event) if event.keycode == KeyEvent::VKF3 @dialog = TradeFilterDialogController.create_instance addnestedcontroller(:dialog, @dialog) status = @dialog.open viewmodel.randomizetrades updatemodel viewmodel, :trades removenestedcontroller(:dialog, @dialog) update_view end endmain view:
endif I run this and try to activate the dialog (via the F3 key press) I receive: Java::JavaLang::IllegalArgumentException - java.lang.IllegalArgumentException: Can not set javax.swing.JButton field tradefilterdialog.TradeFilterDialog.findtradesbutton to java.lang.Long java.lang.IllegalArgumentException: Can not set javax.swing.JButton field tradefilterdialog.TradeFilterDialog.findtradesbutton to java.lang.Long If i comment out the setjavaclass in dialog view it runs and pops up the window, but the button of the window doesn't fire. My guess is that's because the button handler gets tied to the "first" component created by createmainviewcomponent (i.e. no bindings get made) and when I then switch @mainview_component it doesn't retie the actions to the new component. It's a shame the google groups archive was removed, seems there's some threads there I'd like to read. I'd really like to figure out how to do a dialog but it's proving to be pretty hard going.. |
Logan Barnett
|
Posted: December 16, 2009 13:38 by Logan Barnett
|
|
Hopefully this will seem much more clear when I create an example for us to refer to. |
by: sundbp








