Announcement Announcement Module
Collapse
No announcement yet.
Nachocalendar via keyboard... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nachocalendar via keyboard...

    Hi *,

    I was wondering if people were using NachoCalendar for their date mapping?

    I have done so for a while and have used version 0.22 and 0.23.

    I seem to have problem with using the keyboard to navigate, e.g. the arrow keys do not seem to work until I select with the mouse once and then re-open the DatePanel (window with month visible).

    Have you experienced the same thing? It seems to happen if I use it with a base date which is well in the past (rather than assuming 'today').

    Is there anything I could do to workaround this? rather than contacting the author (done) or dive in the code...

    Many thanks

    Benoit

  • #2
    I experience the same thing now that I test the arrow key scenario you speak of. It looks to be an issue in nachocalendar.
    Only other alternative is taking a look at JXDataPicker and see if that has improved meanwhile... and then write a binding and binder for it :/

    Comment


    • #3
      Hi Geoffrey

      Thanks for checking this...so I was not mad... ;-)

      The binder I use now comes from yours but it can handle Date or Joda-time (which I use) and shows weekends and holidays via a registry mechanism... So writing another binder/binding may be of a task...

      I was wondering if somebody had a chance (or need) to dive into the Nachocalendar code and sort it out there... I think it is focus-related...

      May be you'll be able to spot it straight away, it may be a bit beyond me...

      Anybody else?

      Thanks

      Benoit

      Comment


      • #4
        Hi *,

        I think that I have found the problem in DateField. It does require the navigation logic there as well. I will post a Bug report on NachoCalendar (the issue is even on the WebStart demo).

        In the meantime here is 'my' fix... In the WindowPanel of the DateField.java
        Code:
                    KeyListener klistener = new KeyAdapter() {
                        public void keyTyped(KeyEvent e) {
                            if (e.getKeyChar() == 10) {
                                aceptar();
                            } else if (e.getKeyChar() == 27) {
                                cancelar();
                            }
                        }
        
                        // NEW METHOD -> Fix navigation issue.
        public void keyPressed(final KeyEvent e) {
            final int keycode = e.getKeyCode();
            int move = 0;
            int type = Calendar.DAY_OF_YEAR;
            if ((keycode == KeyEvent.VK_LEFT) || (keycode == 226)) {
        	move = -1;
            } else if ((keycode == KeyEvent.VK_RIGHT)) {
        	move = +1;
            } else if ((keycode == KeyEvent.VK_UP)) {
        	move = -7;
            } else if ((keycode == KeyEvent.VK_DOWN)) {
        	move = +7;
            } else if ((keycode == KeyEvent.VK_PAGE_DOWN)) {
        	move = +1;
        	type = Calendar.MONTH;
            } else if ((keycode == KeyEvent.VK_PAGE_UP)) {
        	move = -1;
        	type = Calendar.MONTH;
            }
            if (move != 0) {
        	final Calendar navigation = Calendar.getInstance();
        	navigation.setTime(datepanel.getDate());
        	navigation.add(type, move);
        	datepanel.setDate(navigation.getTime());
            }
        }
                    };
        
                    datepanel.addKeyListener(klistener);
        I hope this helps...

        Has anyone any suggestion in order to select the textfield content when it gets the focus? At the moment, it does not select anything which is poor ergonomics.

        Cheers

        Benoit
        Last edited by benoitx; Sep 25th, 2006, 11:23 AM.

        Comment


        • #5
          Yeepee, looks like I've found a potential solution to the focus issue (sorry for the Swing experts around, this must be so trivial..)

          In DateField, init method, once the field is created add:

          Code:
          field.addFocusListener(new FocusListener() {
              public void focusGained(java.awt.event.FocusEvent e) {
          	SwingUtilities.invokeLater(new Runnable() {
          	    public void run() {
          		field.selectAll();
          	    }
          	});
              }                
          
              public void focusLost(FocusEvent e) {
              }
          });
          Et voila!

          Benoit

          PS: next... suggestion about how one would do a more clever parsing... say I may want to say +3 meaning add 3 days. Or even better, add 3 business days with an integration with the ObjectLab Kit, see http://objectlabkit.sourceforge.net ?

          Comment

          Working...
          X