I am developing a website for nintendo wii which uses "opera" any ways what i want is that while surfing any website on wii we use "wii control"..
So, the control have up/down/right/left keys on it I want those keys to behave like TAB because when you press up/down/right/left keys it scrolls the page..
Note!!! With the TAB i doesnot mean to TAB in the inputfields or text areas... I want to use the tab as we use on our PC's the tab button while we are not using our mouse
I was wondering if i can get a javascript to say something like strat TAB instead of scroll..
document.onkeypress = function(e) {
if (e.keyCode == 175 || e.keyCode == 176 || e.keyCode == 178 || e.keyCode == 177)
alert("pressing keys");
return true;
else if (e.keyCode == 170 || e.keyCode == 174) {
return false;
}
};
Thanks!!
I can't reccomend what you're proposing from a human interface perspective, because it means changing the standard and expected behavior of the controls to something else entirely. This is extremely confusing and frustrating from the user's perspective, especially if you don't give them reasonable enough warning to expect it.
But, giving you the benefit of the doubt, what you'll want to do is:
create a new Keyboard Event:
https://developer.mozilla.org/en/DOM/document.createEvent
initialize the event (with the appropriate information to fake a tab key event):
https://developer.mozilla.org/en/DOM/event.initKeyEvent
and then dispatch the event:
https://developer.mozilla.org/en/DOM/element.dispatchEvent
then put that code into the event handlers for your up/down/left/right keys, and return false from their handlers to suppress the default behavior.
Related
I am currently using Flask to create a website and have come across an interesting issue. There is some code that gives the user the option to input a value in for about 20 separate input fields. What I am trying to do is construct a button that would allow the user to paste in a column from an Excel table. Essentially, a button that will look at the clipboard, take the field, convert the string into an array, and place the values into each input in the order they appear in the list.
So far, I have been able to get the clipboard into a string using tk.Tk().clipboard_get(), and believe that I can get this value by making an XMLHttpRequest, but have had little luck in making it actually work.
Some code for what I am trying to accomplish:
Python:
#app.route('/some/path/here', methods = ['GET'])
def paste():
try:
values = tk.Tk().clipboard_get()
values = values.replace('\n',',')
return values
except:
return None
HTTP:
<button type="button" style="float: right" onclick="Testing()">Paste</button>
<p id="textHere"></p>
JavaScript:
<script>
function Testing() {
var wvpst = new XMLHttpRequest();
wvpst.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200) {
var list = this.responseXML;
// list = list.replace(/'/g,"").replace(/ '/g,"");
// list = list.split(", ");
document.getElementById("textHere").innerHTML = list;
}
}
wvpst.open("GET","{{ url_for('paste') }}",true);
wvpst.send();
}
</script>
For now, I am just trying to get the list of values copied from an Excel sheet, but nothing is being returned when the button is pressed. Am I simply using XMLHttpRequest incorrectly or is there something else I need to do to get this to work?
Set a debug breakpoint inside
if (this.readyState == 4 && this.status == 200) {
}
and inspect your response. Set another on the first line of your function in Flask. Those should give you visibility into where the breakdown is.
A few other, perhaps more important notes:
Point 1) In your flask try/except, on failure you should serve a response, just a 500 response. Replace return None with:
return app.make_response('Couldn't parse clipboard information!'), 500
Point 2) There is no need to pass this information to your server for processing. You can accomplish this within the javascript of the front end and save your server some processing and your client some time waiting on an HTTP response.
Have the user paste their content into a textbox or another element, and then access the value from there.
Direct clipboard access isn't something most browsers give up freely, and so best to avoid that route.
Summary:
Your xmlhttprequest looks fine to me. I would guess that your try in flask is failing and returning something useless if anything at all.
Do this in javascript.
How to handle multiple key press in MFC. I have tried for few key combinations.But How to generalize for all key combination.
BOOL Test::PreTranslateMessage(MSG* pMsg){
if(pMsg->message==WM_KEYDOWN )
{
if(pMsg->wParam == 'C' || pMsg->wParam == 'V')
{
if(GetKeyState(VK_CONTROL) < 0){
}
}
}
}
You can GetKeyState and check what keys are down.
if ((::GetKeyState(_T('C')) & 0x8000)!=0 &&
(::GetKeyState(_T('V')) & 0x8000)!=0)
// C and V are down...
You can do this check whenever a WM_KEYDOWN arrives in your PreTranslateMessage function. Using this for normal keys like accelerating will work. The MFC also does its checks for accelerators in the PreTranslateMessage functions.
You should always use GetKeyState because this function check what keys where down/up when the current message you received from the message queue was processed.
The right way is to handle WM_CUT, WM_COPY and WM_PASTE, because the copy/paste operations could be completed not only Ctrl+C, but CTrl+Insert, and so on ... if you want to handle these things ...
"PreTranslateMessage is dangerous territory": really true ! Take care !
1) when you are in edit mode for one symbol, go into edit for the next symbol in library
2) automatically put cursor in the instance name box for selected movieClip
As far as I know there are is no way to put shorcuts for moving around "inside of the library panel"
A duplicate and edit shortcut would sure be nice though. I can't even find where you would do it in custom shortcuts.
The examples you have listed do not have shortcut keys because they are not default tasks inside of the IDE. That being said you can create ways to do those examples using JSFL to first create a command and then assign a keyboard shortcut to that command. As an example I will include a script for the second item in your list.
2) automatically put cursor in the instance name box for selected
movieClip
There currently isn't a way to tell the IDE to send the cursor to the instance name box in the properties panel, but you can get around that by using JSFL. Let's make our own instance name box pop up.
Here is the code required to do this:
// Assign Instance Name - Andrew Doll
/* This code will provide a prompt for the user to assign an instance name to a selected symbol on the stage. The great thing about using a
// prompt is that the focus is already in the input field of the prompt. To speed up your workflow I recommend assigning a keyboard
// shortcut to this command.
*/
// Check to see if there is a file open first.
var dom = fl.getDocumentDOM();
if (dom == null)
{
alert("Please open a file.");
}
else
{
// Make sure to only select one symbol on the stage at a time.
if (dom.selection.length > 1)
{
alert("You can only select one symbol to assign an instance name to. Please make only a single selection on the stage.");
}
// Make sure that you have at least one symbol selected.
else if (dom.selection.length == 0)
{
alert("You need to select a symbol on the stage to assign an instance name.");
}
// Make sure that the symbol you have selected is a movie clip or a button.
else if (dom.selection[0].symbolType == "graphic" || dom.selection[0].elementType != "instance")
{
alert("Your selection needs to be a button or a movie clip symbol.");
}
else
{
// Pop up a prompt for the user to assign an instance name with.
var iName = prompt("Assign an instance name to the selected symbol.");
// If the user cancels then do nothing.
if (iName == null)
{
// Do Nothing.
}
else
{
// Assign the instance name to the selected symbol.
dom.selection[0].name = iName;
}
}
}
Save this command as a JSFL script in the commands folder in your Flash config directory and then assign a keyboard shortcut to it.
I'm looking a method or way how to check that the text field in crm form is "null"
I've got a tab, there are section and text field inside of it;
furthermore, I'm using that function in order to hide/show tab.
function setVisibleTabSection(tabname, TextFieldName, show) {
var tab = Xrm.Page.ui.tabs.get(tabname);
if (tab != null) {
if (TextFieldName == null)
tab.setVisible(show);
else {
var section = Xrm.Page.data.entity.attributes.get(TextFieldName).getValue();
if (section != null) {
show == true;
tab.setVisible(show);
}
}
}
}
however, It doesn't work. There is nothing inside of the text box, and the tab expanded anyway.
by the way, parameters, which I give the function: "tab_8", "new_conf_report", false
where the secon one the name of the text field
Try
if (section != null && section !="")...
You may find that a field which is initially blank is null, whereas one from which you have deleted content but not yet saved the form is simply an empty string.
Certainly worth a shot.
show==true
is incorrect as others have pointed out (needs to be show=true) but is simply redundant as written inside the same IF statement, just replace next line as:
tab.setVisible(true);
It is possible you intended "show" to be the default tab state to use if text field is not empty, in which case just move this line outside the IF instead of changing it (as shown below)
It looks like the construction using the third "show" parameter is to allow you to use the function to set the tab state to a specific state of shown or not without looking for a text field value at all. You would need to pass parameters as eg tabname,,true - you might consider swapping the TextFieldName and Show parameters so it is easier to just drop the third rather than remember to double-comma.
While we're fixing stuff, lets replace that variable "section" with something with a more meaningful name:
function setVisibleTabSection(tabname, show, TextFieldName) //usage: show is state Tab will have if no TextFieldName is specified, or if text field is empty
{
var tab = Xrm.Page.ui.tabs.get(tabname);
if (tab != null)
{
if (show==null){show=true;}
if (TextFieldName == null)
{
tab.setVisible(show);
}
else
{
var strFieldValue = Xrm.Page.data.entity.attributes.get(TextFieldName).getValue();
if (strFieldValue != null && strFieldValue !="")
{show=true;}
tab.setVisible(show);
}
}
}
I don't see anything wrong with your Javascript (besides what Guido points out, which basically will only set the tab to visible if you pass in true for show). Use the debugging tool within IE by pushing F12, and set a break point at the top of your function to see where your logic is failing.
If you've never debugged javascript before, see http://social.technet.microsoft.com/wiki/contents/articles/3256.how-to-debug-jscript-in-microsoft-dynamics-crm-2011.aspx
or
How to debug jScript for Dynamics CRM?
I think there is a typo in the code:
show == true;
actually the code (assuming "=" instead of "==") will show always the tab if TextFieldName isn't empty, removing that line will show/hide the tab according to show parameter value
It seems to work when I run it but I'm not sure what you'd expect it to do so it might not be working the way you'd like it to. :)
function setVisibleTabSection(tabName, textFieldName, show) {
var tab = Xrm.Page.ui.tabs.get(tabName);
if(!tab) return;
if (!TextFieldName)
tab.setVisible(show);
else {
var section = Xrm.Page.data.entity.attributes.get(textFieldName).getValue();
if (section)
tab.setVisible(true);
}
}
I've created a simple mapping widget using Dojo and Google Maps. The map is displayed in a dijit.layout.ContentPane set as the center panel of a dijit.layout.BorderContainer (which has the address field and a BusyButton in its top panel); the BorderContainer is in turn wrapped in a dojox.layout.FloatingPane. The widget has a subscription to a topic that will trigger a refresh of the map display when new address data is provided. The updater function is very simple, and looks like this:
_updateAddress: function(data) {
this.addressMapper.show();
if (data === null || !data.address || data.address === "" ) {
this.address.attr("value", "");
} else {
this.address.attr("value", data.address);
}
this.mapBtn.makeBusy();
this._getMap();
}
Every time I call this function, the FloatingPane's resize() method is invoked when I call show(), and it's increasing the height and width of the BorderContainer by 12 pixels every time the pane is shown (even with doLayout and isLayoutContainer set to false on the FloatingPane). I can't seem to prevent this from happening, or correct it afterwards, no matter what I try.
Anyone have any ideas how to remedy this?
Thanks in advance!
-- Joe M --