Key input

Hi
We have implemented GoWeb in a web part in the web part framework that comes with ASP.Net 2.0. We have two issues, but they could very well be related as they are connected to events.

  1. Node doesn’y get focus on first click. When the page is first loaded the diagram doesn’t fire the GoView.ObjectSingleClicked event. However on the next click and all subsequent clicks the events is fired. The only time it’s not firing is when the page is fresh (as in no postbacks occured yet). I suspect it has to do with my event handler creation or similar. My view and event handler is created in WebPart.OnInit(), even before InitializeComponent() is called.
  2. Issue two is key input is not handled. Nothing happens when I click the delete key on the keyboard. When I tried ctrl-a to select all, the whole page is selected in MS way (blue-ish).
    Any ideas here? I can provide source code (somewhat messy) if that would help.
    Thanks!
    -Kjelli
  1. I haven’t tried using GoDiagram Web in web parts yet. Does the part have to get focus before individual controls within the part can get events?
    (By the way, nodes and other GoObjects cannot get “focus” because there is no notion of individual objects getting keyboard events. However, they can show selection handles because they were selected, for example because someone clicked on them to select them.)
  2. The browser window/control is handling all keyboard events. Here’s the relevant section from the documentation:

The predefined JavaScript can also handle key press events. However, the IMG tag cannot handle onKeyDown. Instead, if you want keystroke commands to be passed onto your GoView, you will need to add the event handler declaration on the HTML BODY:

<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

In doing this, you are limiting the user to passing the key press events to just one view. Often there can be conflicts and confusion with the keys that are handled by the browser, so handling keystrokes is not common. The Control-A key handled by the browser is an example of the last sentence.

Thanks for your reply walter!

  1. No, all webparts are ready for input at the same time. No activation. I follow you on the focus subject. My focus term is actually “selected” as you point out. Any clue why it takes an exstra postback to select the first time?
  2. I’ll leave this decision to the project manager. A “delete selection” button is probably just as good.
  1. Sorry, I don’t know. In Windows Forms there is some complexity in GoView regarding focus, but in Web Forms it’s pretty simple and straight-forward.
    Maybe you could experiment by modifying GoWeb.js to add an alert to the beginning of the goPost method, just to make sure the mouse click really is being detected and causing a server request. (goPost is called both for postbacks and for NoPost requests.)