How to navigate cells using TAB key in dgrid - dgrid

I am trying to enable cell navigation in dgrid using TAB key. (get the same behaviour as with the right arrow key). I have gotten as far as using the keyMap property as explained in the docs. How do I move focus to the next cell now ?
keyMap: lang.mixin({}, Keyboard.defaultKeyMap, {
9: function(event) {
event.preventDefault();
Keyboard.moveFocusRight(event);
}
})
Is this right way?

Ok. I got it working this way as explained here
grid.addKeyHandler(keys.TAB, Keyboard.moveFocusRight);

Related

How to open a hyperlink in separate browser tab in Coded UI

I have three different Hyperlinks on a web page
Planning.
Solutions.
Contact Us.
I want to open them in separate browser tab one by one using codedUI.
i have written the above code to obtain the list of Hyperlink
HtmlControl Hyperlink = new HtmlControl(browser);
Hyperlink.SearchProperties.Add(HtmlControl.PropertyNames.ControlType,"Hyperlink");
UITestControlCollection controls = Hyperlink.FindMatchingControls();
foreach(UITestControl control in controls)
{
if (control is HtmlHyperlink)
{
HtmlHyperlink link = (HtmlHyperlink)control;
if(link.InnerText=="Planning"|| link.InnerText== "Solutions")
{
//separate Tab logic goes here
}
}
}
I need the help related to opening a hyperlink in new browser tab. Is it possible in CodedUI ?
By default if you click the mouse middle button (or click the scroll wheel), it opens a link in new tab. I would modify your code as below in this case,
if(link.InnerText=="Planning"|| link.InnerText== "Solutions")
{
//Open Link in New tab, by clicking middle button
Mouse.Click(link, MouseButtons.Middle);
}
You can do this a couple different ways. I would use #Prageeth-Saravan 's approach first to see if it works because it's easier and actually tests your UI. You could also:
Get the URL from the found link control
Send the "New tab" keyboard shortcut
Reinstantiate your browser window object to be sure it's pointing to the new tab
Navigate to that URL
The reason why I bolded step 3 is regardless of approach, if you intend to assert or interact with anything in a new tab you're going to have to remember that the CodedUI software will still be "Looking" at the old tab until you reinitialize it.

Primefaces hotkey while input has focus

I’m developing web app using Primefaces and one of the requirements is that hotkeys should work. And they do but there is a catch. While reading documentation I found out that hotkeys hotkey will not be triggered if there is a focused input on page. And this is big show stopper for us. Is there a way to make at least some hotkeys like F1, F2, ESC etc. work?
One way to achieve that is to manually bind the hotkeys to the inputs you choose.
I don't know your personal needs, but the following code (in jQuery) will bind it to all input, textarea, select and button elements.
$(':input').keydown(function (event) {
if (event.which == 112) { //you could also make a switch :)
alert('f1 pressed!'); //do what you want
}
if (event.which == 113) {
alert('f2 pressed!'); //do what you want
}
//...
})
Also don't delete your p:hotkeyto continue with its normal behavior.
Note: Search for javascript keycode if you want to know more codes.

How to write an extension to close tabs on "back" attempt when there's no previous page?

I find myself more and more using the touchpad gesture of 3 fingers to the left or right in order to perform a "back" or "forward" in Google Chrome (on my Asus Zenbook, but I believe there's a similar gesture on Macs)
I found that when browsing, I open a tab to read something (Like a like from Twitter or Facebook) and when I'm done my instinct is to go "back" to get back to the previous tab I was browsing on. (I think I got that instinct from using Android a lot).
I figured that I need a Chrome extension that would close my current tab if I'm attempting to go "back" in a tab that doesn't have a previous page in its history.
I went over the Chrome events and various methods I can invoke and while there's a "forward_back" transition qualifier in the WebNavigation api, the onCommitted event doesn't fire when attempting to go "back" using the touchpad gesture or Alt+left keyboard shortcut.
Also, I couldn't find how I can access a current tab's history to see if the page I'm at doesn't have a previous one in the stack.
Ideas anyone?
function noHistory(tabId) {
// TODO
}
function getCurrentTabId() {
// TODO
}
function userHitBack() {
tabId = getCurrentTabId();
if (noHistory(tabId)) {
chrome.tabs.remove(tabId)
}
}
function attachEvent() {
// TODO attach userHitBack
}
attachEvent();
To catch the "back" event, you need to handle specific key pressed to call your "userHitBack" function. Something like this:
document.onkeydown = function() {
if (keyId == ...)
userHitBack()
}
You can use this to your advantage as you can bind any key to trigger the close of the tab.
To check the tab history length use this:
window.history.length
It is html5 historyAPI

JavaME Nokia Maps API: how to display additional info on marker click?

I need to display an additional info for a marker when it's clicked. I expected to find a way how to display a popup window (like a tooltip) with a short description on marker click, but failed.
I use MapMarker class for my markers because I need custom icons.
The MapMarker and MapStandardMarker classes do not have the functionality I need.
As I understand, I need something like Android MapView Balloons
I've solved the problem.
I use the popup dialog similar to the one implemented in "Meet Me For Dinner" sample application. All necessary info can be found here.
I met the problem with detecting a click on marker. For this I used MapDisplay.getObjectAt () method. But it looks like that method doesn't take into account the marker's anchor point. So, I had to use the following work-around for this:
final MapObject mapObj = mapDisp.getObjectAt ( new Point (
clickX + m_markerIconSize.getWidth (),
clickY + m_markerIconSize.getHeight () )
);
if ( (mapObj != null) && (mapObj instanceof MapMarker) ) {
I worked on Google MID-MAPS, There is no any method to show balloon in MapMarker but you can try with your own method create your own balloon. When user clicks particular position of map you can show your balloon. I never tried this but lets try and let me know also.
Thanks

Capturing the delete/backspace keys in SproutCore

I have a SproutCore Pane - a PalettePane, specifically - which includes a form tied to an object elsewhere on the screen. The Pane is causing trouble with the object deletion interaction. The way I want it to work is:
If a text input field is in focus, the backspace/delete keys should apply to those fields (i.e. editing the text)
If no text input field has focus, the backspace/delete keys should delete the selected object related to the form. (The pane appears when the user has selected an object, so if the pane exists there's a selected object.)
So far, I get one of these behaviors or the other, never both. If I set acceptsKeyPane: YES in the Pane, I get the backspace/delete keys applying to the text fields, but no deleting of selected objects when the text fields don't have focus. If I use acceptsKeyPane: NO, when I'm editing a text field and hit backspace, it deletes the object I was trying to edit.
To add insult to injury, in Firefox with acceptsKeyPane: YES the backspace key is caught by the browser and interpreted as a back-button click, which is going to be frustrating to the user.
I've looked at the root_responder.js code and it looks like SproutCore handles backspaces differently for Firefox, but if I can handle them as described above the distinction between FF and other browsers should be moot.
ETA May 2011: Bear in mind when reading answers here that the SproutCore API for 1.5, 1.6 and beyond may not be the same as this.
Here's how we finally wound up doing it:
When the pane was created, we called becomeFirstResponder() on it.
We added acceptsFirstResponder: YES to its view definition.
Then we added to the view definition:
keyDown: function(evt) {
return this.interpretKeyEvents(evt) ? YES : NO;
},
deleteBackward: function() {
this.get('objectToEdit').destroy();
return YES;
},
deleteForward: function() {
this.get('objectToEdit').destroy();
return YES;
}
...and that did the trick.

Resources