[JS CS4/CS5] ScriptUI Click Event Issue in JSXBIN
Still working on a huge ScriptUI project, I discovered a weird issue which appears to *only* affect 'binary compiled' scripts (JSXBIN export), not the original script!
When you repeatedly use addEventListener() with the same event type, you theorically have the possibility to attach several handlers to the same component and event, which can be really useful in a complex framework:
// Declare a 'click' manager on myWidget (at this point of the code)
myWidget.addEventListener('click', eventHandler1);
// Add another 'click' manager (for the same widget)
myWidget.addEventListener('click', eventHandler2);
When you do this, both eventHandler1 and eventHandler2 are registered, and when the user clicks on myWidget, each handler is called back.
The following script shows that this perfectly works in ID CS4 and CS5:
// Create a dialog UI
var u,
w = new Window('dialog'),
p = w.add('panel'),
g = p.add('group'),
e1 = p.add('statictext'),
e2 = p.add('statictext');
// Set some widget properties
e1.characters = e2.characters = 30;
g.minimumSize = [50,50];
var gx = g.graphics;
gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
// g->click Listener #1
g.addEventListener('click', function(ev)
e1.text = 'click handler 1';
// g->click Listener #2
g.addEventListener('click', function(ev)
e2.text = 'click handler 2';
w.show();
The result is that when you click on the group box, e1.text AND e2.text are updated.
But now, if I export the above code as a JSXBIN from the ESTK, the 2nd event handler sounds to be ignored! When I test the 'compiled' script and click on the group box, only e1.text is updated. (Tested in ID CS4 and CS5, Win32.)
By studying the JSXBIN code as precisely as possible, I didn't find anything wrong in the encryption. Each addEventListener() statement is properly encoded, with its own function handler, nothing is ignored. Hence I don't believe that the JSXBIN code is defective by itself, so I suppose that the ExtendScript/ScriptUI engine behaves differently when interpreting a JSXBIN... Does anyone have an explanation?
@+
Marc
John Hawkinson wrote:
Not an explanation, but of course we know that in JSXBIN you can't use the .toSource() method on functions.
So the implication here is that perhaps the .toSource() is somehow implicated in event handlers and there's some kind of static workaround for it?
Perhaps you can get around this by eval() or doScript()-ing strings?
Thanks a lot, John, I'm convinced you're on the good track. Dirk Becker suggested me that this is an "engine scope" issue and Martinho da Gloria emailed me another solution —which also works— and joins Dirk's assumption.
Following is the result of the various tests I did from your various suggestions:
// #1 - THE INITIAL PROBLEM// =====================================
// EVALUATED BINARY CODE
var handler1 = function(ev)
ev.target.parent.children[1].text = 'handler 1';
var handler2 = function(ev)
ev.target.parent.children[2].text = 'handler 2';
var u,
w = new Window('dialog'),
p = w.add('panel'),
g = p.add('group'),
e1 = p.add('statictext'),
e2 = p.add('statictext');
e1.characters = e2.characters = 30;
g.minimumSize = [50,50];
var gx = g.graphics;
gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
g.addEventListener('click', handler1);
g.addEventListener('click', handler2);
w.show();
eval("@JSXBIN@[email protected]@MyBbyBn0AKJAnASzIjIjBjOjEjMjFjShRByBNyBnA . . . . .");
// RESULT
// handler 1 only, that's the issue!
Now to John's approach:
// #2 - JOHN'S TRICK
// =====================================
var handler1 = function(ev)
ev.target.parent.children[1].text = 'handler 1';
var handler2 = function(ev)
ev.target.parent.children[2].text = 'handler 2';
// EVALUATED BINARY CODE
var u,
w = new Window('dialog'),
p = w.add('panel'),
g = p.add('group'),
e1 = p.add('statictext'),
e2 = p.add('statictext');
e1.characters = e2.characters = 30;
g.minimumSize = [50,50];
var gx = g.graphics;
gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
g.addEventListener('click', handler1);
g.addEventListener('click', handler2);
w.show();
eval("@JSXBIN@[email protected]@MyBbyBn0AIbCn0AFJDnA . . . . .");
// RESULT
// handler1 + handler2 OK!
This test shows that if handler1 and handler2's bodies are removed from the binary, the script works. Note that the handlers are declared vars that refer to (anonymous) function expressions. (BTW, no need to use a non-main #targetengine.) This is not a definitive workaround, of course, because I also want to hide handlers code...
Meanwhile, Martinho suggested me an interesting approach in using 'regular' function declarations:
// #3 - MARTINHO'S TRICK
// =====================================
// EVALUATED BINARY CODE
function handler1(ev)
ev.target.parent.children[1].text = 'handler 1';
function handler2(ev)
ev.target.parent.children[2].text = 'handler 2';
var u,
w = new Window('dialog'),
p = w.add('panel'),
g = p.add('group'),
e1 = p.add('statictext'),
e2 = p.add('statictext');
e1.characters = e2.characters = 30;
g.minimumSize = [50,50];
var gx = g.graphics;
gx.backgroundColor = gx.newBrush(gx.BrushType.SOLID_COLOR, [.3, .6, .9, 1]);
g.addEventListener('click', handler1);
g.addEventListener('click', handler2);
w.show();
eval("@JSXBIN@[email protected]@MyBbyBnACMAbyBn0ABJCnA . . . . .");
// RESULT
// handler1 + handler2 OK!
In the above test the entire code is binary-encoded, and the script works. What's the difference? It relies on function declarations rather than function expressions. As we know, function declarations and function expressions are not treated the same way by the interpreter. I suppose that function declarations are stored at a very persistent level... But I don't really understand what happens under the hood.
(Note that I also tried to use function expressions in global variables, but this gave the original result...)
Thanks to John, Dirk, and Martinho for the tracks you've cleared. As my library components cannot use neither the global scope nor direct function declarations my problem is not solved, but you have revealed the root of my troubles.
@+
Marc
Similar Messages
-
[CS4/CS5] ScriptUI focus event (Win/Mac)
Hi friends,
I'm looking after a way to control the focus of EditText widgets within a Dialog but I'm totally confused by the event loop logics —especially in Mac OS.
The basic task I need to achieve is to attach a validation mechanism to an EditText. When the user has entered a wrong field and the change event occurs, I want to display an alert box, then re-activate the field. The problem is that both the change event and the alert box interfer with focus attribution. I think that user or system focus/blur events are stacked so that any command that attempts to focus back to the original widget cannot work while the stack is not empty.
Here is a simple test to illustrate my problem. The script is supposed to display an alert when the user change a field, then it tries to focus back to the corresponding field through myWidget.active = true. This does not work.
var u,
w = new Window('dialog',u,u,{xname:'Window'}),
e1 = w.add('edittext', u, "",{xname:'EditText (1)'}),
e2 = w.add('edittext', u, "",{xname:'EditText (2)'}),
eInfo = w.add('edittext', [0,0,300,400], "",{xname: 'EditText (Info)', multiline:true}),
b = w.add('button',u,'Clear', {xname:'Button'});
e1.characters = e2.characters = 20;
var anyEvent = function(ev)
var tg = ev.target;
eInfo.text += (tg.properties.xname + ' -> ' +
ev.type.toUpperCase() +
(tg.active ? ' (active)':' (non active)') +
'\n');
var changeEvent = function(ev)
eInfo.text += ('\n--- BEFORE Breaking Alert\n');
alert("Breaking alert");
// Trying to FOCUS back on ev.target
eInfo.text += ('\n--- BEFORE Active=true\n');
ev.target.active = true;
eInfo.text += ('--- AFTER Active=true\n');
// Event 'inspector'
w.addEventListener('change', anyEvent);
w.addEventListener('focus', anyEvent);
w.addEventListener('blur', anyEvent);
// Events
w.addEventListener('change', changeEvent);
b.onClick = function(){eInfo.text = '';};
w.show();
I tried various strategies to address this problem by using event timestamps and/or dispatching custom new UIEvent('focus'...), but nothing works conveniently.
In addition I got odd behaviours in Mac OS. The below screenshot shows a piece of a ScriptUI dialog —using a custom framework, so don't be surprised by the skin! What is weird is that in a particular state *two* EditText controls have the focus ring at the same time:
I didn't know such a thing could happen. I probably did not understand anything about the 'focus' paradigm.
Any help from an expert would be greatly appreciated. Thanks a lot!
@+
MarcHarbs. wrote:
It does seem to change the focus, but you are still left with a cursor sometimes (which does not work).
The one that has the focus rect allows input and .active = true seems to work fine. (Mac 10.6 CS5)
Harbs
Well, this is not so clear to me. My beta-tester —also Mac CS5— reports unpredictable behaviors. It also depends on how the user change the focus: using the TAB key and clicking into another field are not equivalent. (It seems that the change-focus-by-click event is more complicated to counteract...)
But generally, on Mac platforms, we cannot be sure that setting myEditText.active = true gives the focus back to myEditText when other user events are running. The problem is that the active property is not always 'reliable'. We found that (under unstable circumstances) e1.active might returns true while e2 actually owns the focus ring! Somehow, Mac systems can dissociate the 'active' control and the focus... I don't know.
My assumption is that the focus has a high level priority in the Mac event loop and that it closely mirrors the user interaction, while the active property is an abstract thing featured by the ScriptUI layer. The purpose of ScriptUI is to wrap OS events and widgets in a single scripting interface for both Mac and Win, but ScriptUI is nothing but a bridge. I suppose that "myWidget is active" and "myWidget has the focus" means exactly the same thing in Windows, so ScriptUI can easily target the focus through the active property in Win environment. But Mac OS doesn't work the same way.
Interestingly when we set an EditText as borderless in Windows, we entirely remove the default widget appearence. On the contrary, a borderless EditText in Mac still reserve an additional region for the focus and there is no way to hide the focus ring when the control receives the inputs.
In addition, I posted above a screenshot where two EditText instances have the focus ring at the same time. I'm not a Mac user but I was told that this is not a normal situation. Then playing with the active property in ScriptUI can really disrupt the focus behavior on Mac platforms...
My first idea was to study more closely event triggering and to use a timestamp-based routine to keep the control of the focus. So I sent the following script to my beta-tester:
var u,
w = new Window('dialog',u,u,{xname:'Window'}),
e1 = w.add('edittext', u, "aaa",{xname:'(1)'}),
e2 = w.add('edittext', u, "",{xname:'(2)'}),
eInfo = w.add('edittext', [0,0,300,400], "",{xname: '(Info)', multiline:true}),
cForce = w.add('checkbox', u, "Force default value on error"),
b = w.add('button',u,'Clear', {xname:'(Button)', name:'ok'});
e1.characters = e2.characters = 20;
var fgTarget = null,
fgTimeStamp = +new Date,
fgAlerting = null,
fgNonValid;
var blurEventHandler = function(ev)
if( fgAlerting ) return;
var d = +new Date - fgTimeStamp;
if( 100 < d )
eInfo.text = '';
fgTarget = ev.target;
fgTimeStamp = +new Date;
fgAlerting = null;
fgNonValid = isNaN(fgTarget.text);
d += ' ms';
eInfo.text += (ev.target.properties.xname + ' is losing the focus ' + d + '\n');
fgTarget.active = true;
if( fgNonValid )
eInfo.text += (' Re-activate ' + fgTarget.properties.xname +
' from '+ ev.target.properties.xname + '\n' +
' w.active=' + w.active + '\n' +
' e1.active=' + e1.active + '\n' +
' e2.active=' + e2.active + '\n') ;
if( null===fgAlerting )
fgAlerting = true;
eInfo.text += '--- ALERT ---\n';
alert("Please enter a numeric value or let the field empty.");
fgAlerting = false;
if( cForce.value ) fgTarget.text = '50';
fgTimeStamp = +new Date;
e1.addEventListener('blur',blurEventHandler);
e2.addEventListener('blur',blurEventHandler);
var anyEventHandler = function(ev)
eInfo.text += (ev.target.properties.xname + ' -> ' + ev.type + '\n');
e1.addEventListener('mousedown',anyEventHandler);
e1.addEventListener('mouseup',anyEventHandler);
e1.addEventListener('keydown',anyEventHandler);
e1.addEventListener('keyup',anyEventHandler);
e2.addEventListener('mousedown',anyEventHandler);
e2.addEventListener('mouseup',anyEventHandler);
e2.addEventListener('keydown',anyEventHandler);
e2.addEventListener('keyup',anyEventHandler);
b.onClick = function(){eInfo.text='';}
e1.active = true;
w.show();
This script gives unstable results. ScriptUI does not always report every event that actually occurs.
But as a general rule, what the user has done supersedes what the script can do.
Any help from ScriptUI / Mac gurus would be highly welcome.
@+
Marc -
CSS issues....get Javascript error on click event
Trying to finish up this navbar. Got it where my navigation works pretty much great. However, the code I expected to work when I fire a click event on the logo (represnted currently by a gray circle) causes a 'Javascript error in event handler! Event Type = element' error instead. Not sure why. I know I had an issue with one of my button references (spelling issue) but beyond that, everything seems to be in order.
This is the code I'm using. The first five lines work right. The second series does not.
sym.getSymbol("btnVision").$("back").css({opacity: 0})
sym.getSymbol("btnIndustires").$("back").css({opacity: 1})
sym.getSymbol("btnResp").$("back").css({opacity: 1})
sym.getSymbol("btnCommunity").$("back").css({opacity: 1})
sym.getSymbol("btnDiscovery").$("back").css({opacity: 1})
var stage = sym.getComposition().getStage()
stage.$("navVision").css({top: 65});
stage.$("navIndustries").css({top: 65});
stage.$("navResp").css({top: 65});
stage.$("navCommunity").css({top: 65});
stage.$("navDiscovery").css({top: 65});
I should mentioned I tried sym.getSymbol for the bottom entries but that simply produced the same exact error. Sign.
Anyone know what might be causing this? It doesn't seem to make sense to me. Here's the files.
https://www.dropbox.com/s/xo90u6hvj65ix78/nav.zipHi ladobeugm,
The error message is rather cryptic, but this occurs when trying to access something not defined, as you already experienced with your misspelling.
You should use Firebug to localize the error via step by step execution. There is a Scripts tab. In its menu, select <youProject>Actions.js. Then, define a breakpoint by clicking in the line number of statement var stage= etc. In the Spies area, you can look for the offending statement by monitoring variable values.
Gil -
ALV: Issue with double click event after sorting the ALV
Hello Experts,
I have an internal table that populates an ALV grid. When the user doubleclicks a row, my method HANDLE_DOUBLE_CLICK returns the e_row-index value from the ALV Grid. I use this index value to read the internal table, then retrieve additional data.
My problem is the user may sort the ALV grid before double clicking on a line. If this happens my internal table is not sorted to match the ALV grid, so reading the internal table with the e_row-index value returns the wrong information.
When the double click event occurs, is it possible to capture the value in column 1 instead of a value for e_row-index?
There is one more paramter in HANDLE_DOUBLE_CLICK for row id. It is coming blank in debugging . what is the purpose of this parameter and how i can make use of it ?
Regards
VivekHi,
I am Posting The Code Which Uses Double Click Event.
And This Code will provide the total information to you.
REPORT ZALVGRID_PG.
TABLES: SSCRFIELDS.
DATA: V_BELNR TYPE RBKP-BELNR.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: IRNO FOR V_BELNR.
PARAMETERS: P_GJAHR TYPE RBKP-GJAHR.
SELECTION-SCREEN END OF BLOCK B1.
DATA: WA TYPE ZALVGRID_DISPLAY,
ITAB TYPE STANDARD TABLE OF ZALVGRID_DISPLAY.
DATA: IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: L_TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE.
TYPE-POOLS: SLIS,SDYDO.
DATA: L_LOGO TYPE SDYDO_VALUE,
L_LIST TYPE SLIS_T_LISTHEADER.
END-OF-SELECTION.
CLASS CL_LC DEFINITION.
PUBLIC SECTION.
METHODS: DC FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN.
ENDCLASS.
CLASS CL_LC IMPLEMENTATION.
METHOD DC.
DATA: WA1 TYPE ZALVGRID_DISPLAY.
READ TABLE ITAB INTO WA1 INDEX E_ROW-INDEX.
BREAK-POINT.
SET PARAMETER ID 'BLN' FIELD WA1-BELNR.
CALL TRANSACTION 'FB02'.
ENDMETHOD. "DC
ENDCLASS.
DATA: OBJ_CL TYPE REF TO CL_LC.
START-OF-SELECTION.
PERFORM SELECT_DATA.
IF SY-SUBRC = 0.
CALL SCREEN 100.
ELSE.
MESSAGE E000(0) WITH 'DATA NOT FOUND'.
ENDIF.
INCLUDE ZALVGRID_PG_STATUS_0100O01.
INCLUDE ZALVGRID_PG_LOGOSUBF01.
INCLUDE ZALVGRID_PG_SELECT_DATAF01.
INCLUDE ZALVGRID_PG_USER_COMMAND_01I01.
***INCLUDE ZALVGRID_PG_STATUS_0100O01 .
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'AB'.
* SET TITLEBAR 'xxx'.
IF IDENTITY IS INITIAL.
CREATE OBJECT IDENTITY
EXPORTING
CONTAINER_NAME = 'ALVCONTROL'.
CREATE OBJECT GRID
EXPORTING
I_PARENT = IDENTITY.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'ZALVGRID_DISPLAY'
CHANGING
IT_OUTTAB = ITAB.
CREATE OBJECT OBJ_CL.
SET HANDLER OBJ_CL->DC FOR GRID.
ENDIF.
IF L_IDENTITY IS INITIAL.
CREATE OBJECT L_IDENTITY
EXPORTING
CONTAINER_NAME = 'LOGO'.
CREATE OBJECT L_TREE
EXPORTING
I_PARENT = L_IDENTITY.
PERFORM LOGOSUB USING L_LOGO.
CALL METHOD L_TREE->CREATE_REPORT_HEADER
EXPORTING
IT_LIST_COMMENTARY = L_LIST
I_LOGO = L_LOGO.
ENDIF .
ENDMODULE. " STATUS_0100 OUTPUT
***INCLUDE ZALVGRID_PG_LOGOSUBF01 .
FORM LOGOSUB USING P_L_LOGO.
P_L_LOGO = 'ERPLOGO'.
ENDFORM. " LOGOSUB
***INCLUDE ZALVGRID_PG_SELECT_DATAF01 .
FORM SELECT_DATA .
SELECT RBKP~BELNR
RBKP~BLDAT
RSEG~BUZEI
RSEG~MATNR
INTO TABLE ITAB
FROM RBKP INNER JOIN RSEG
ON RBKP~BELNR = RSEG~BELNR
WHERE RBKP~BELNR IN IRNO
AND RBKP~GJAHR = P_GJAHR.
ENDFORM. " SELECT_DATA
***INCLUDE ZALVGRID_PG_USER_COMMAND_01I01 .
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
EXIT.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Warm Regards,
PavanKumar.G
Edited by: pavankumar.g on Jan 19, 2012 5:30 AM -
Issues with click events and nested ellipse objects
I thought by now, I'd have this, but after a number of attempts, nothing is working.
Got a series of circular objects nested inside drawn using the ellipse tool in An of a sumbol called 'box' Click event in each symbol. When clicked, symbol should either hide or change CSS attributes or anything really. Tried a bunch of examples and there's four variations in my .zip file. None of them work and some are ones I've used previously. So I don't get why this isn't working and what the correct code should be. Tried getSymbol, Stage and Composition. None of them worked. So what does?Hi, ladobeugm-
Try:
sym.$("c1").hide();
This is the same as:
sym.getSymbol("c1").getSymbolElement().hide();
sym.getStage().getComposition().getSymbol("box").$("c1").hide();
sym.getStage().getComposition().getSymbol("box").getSymbol("c1").getSymbolElement().hide() ;
Hope that helps!
-Elaine -
Js ctrlKey or metaKey don't work in OS X in click event
When checking for ctrlKey and metaKey in click event, I always get false. Photoshop CC 2014
I'm sorry, but I shouldn't have to go back to 10.5.8 to get features of my app to work. All other apps work fine using Rosetta. But, not droplets in PS, even when I'm running it under Rosetta. Apple has made updates to 10.6 to address problems with Adobe products, namely issues with saving, printing etc. Surely they didn't do this without some collaboration with Adobe? Am I going to have to wait for CS5 before droplets and other such features work in 10.6? I'd gladly take the issue up with Apple, but they'd tell me that it isn't their product and to contact Adobe, which is more or less the case here. Unless Adobe has CS5 coming out in the next couple of months isn't it reasonable to suggest that Adobe work with Apple to correct some of these issues? Perhaps Adobe could discover why droplets don't work in Rosetta, which would essentially be the same as reverting back to 10.5.8 for the specific app. I understand very well how updates of any kind can cause issues. But a lack of effort to remedy these issues by either party involved is simply not fair. "Oh well" just isn't acceptable anymore. If Adobe or Apple made a noticeable effort and still failed to correct the issues, then fine. Some things can't be fixed. However, I suspect that in this case the issues have been given little attention.
-
Cs4/Cs5 PS - Menu bar drives me nuts
Is that possible to eliminate that gap between the top menu bar and the top screen edge?
It's very irritating that when I move my mouse to the top edge I cannot unfold menus with a click. I have to move the pointer down
a bit. It's like shooting ducks and hinders work.
I saw that in Cs4 trial but hoped it would be brought back to normal in cs5 when finally I want to upgrade.
Hope I'm missing some settings...
Joey33Yes Jesper, couldn't be further from truth - the area at the top alongside the edge is for functionalities reserved for windows, not necessarily for unfolding menus.
However, previous versions (at least the ones I've been using 7-9) allowed for 3 modes of workspace - 1 stnd and 2 full screen (with and without menu bar).
The difference with CS4/Cs5 is that when working in mode 2 - full screen + menu bar, you can NO LONGER access/unfold menus by clicking at the very edge of the screen.
Since I've grown used to that for years, it's really frustrating and odd that it has been changed. Apart from keyboard shortcuts I do use menu a lot and now
the workflow is hindered indeed.
It was simultaneous with the 'application frame' introduced in CS4 - probabaly then this dead area in full screen mode appeared.
To be precise and well-understood - it is an issue in FULL SCREEN PLUS MENU BAR.
Regards,
Joey33 -
Hi all,
Is there any chance I can propagate custom events in ScriptUI ? I tried this sample in ESTK and it works fine. However I tried to run it in several CS apps and all my attempts raised errors. My intenttion is to create custom components that would throw events listened by the parent window. Am I asking too much ?
function test()
var w = new Window('dialog');
var btn = w.add('button');
w.addEventListener ('custom', tata);
btn.onClick = function()
w.close()
var e = new UIEvent('custom', true, true, w, null);
e.data= {test:"hello"};
w.dispatchEvent(e)
function tata(e)
alert(e.data.test);
w.show();
test();
Thanks for any hint/advice,
LoicHi Loïc,
To my knowledge new UIEvent(…) works fine in InDesign (CS4/CS5/CS6) provided that you let the view parameter undefined.
So just try to replace:
var e = new UIEvent('custom', true, true, w, null);
by:
var e = new UIEvent('custom', true, true);
Note: Usually a custom UI event should be dispatched from a specific target—in your case: btn.dispatchEvent(e)—rather than from the top window. This way you can have multiple listeners that the event will hit during the bubbling phase:
// Propagation of a custom UI event (which bubbles)
// Tested in ID CS4/CS5/CS6
const EV_TYPE = 'MyCustomEventType';
var u,
w = new Window('dialog'),
p = w.add('panel'),
b = p.add('button',u,"Test"),
evHandler = function(ev)
alert( this + " is listening: " + ev.data );
myDispatcher = function(data)
var ev = new UIEvent(EV_TYPE, true, true);
ev.data = data;
this.dispatchEvent(ev);
w.addEventListener(EV_TYPE, evHandler);
p.addEventListener(EV_TYPE, evHandler);
b.onClick = function(){ myDispatcher.call(this, "Some data"); }
w.show();
@+
Marc -
CS6 Beta Modifies CS4 & CS5 Bridge File Associations (W7 Pro 64Bit SP1)
Symptoms:
After installing CS6 including bridge CS6 onto a W7 pro 64Bit Machine with SP1.
The File associations in the existing copies of CS4 and CS5 bridge are updated to make the CS6 Beta the default programme for opening the majority of file types from either CS4 or CS5 bridge.
When right clicking ona file from CS4/5 bridge only the option of opening in CS6 is presented
Expected Bahaviour:
I expected that CS6 would be the default programme launched from CS6 bridge but that CS4/CS5 would remain the default programmes launched from their own versions of bridge.
Setting CS6 as the default file association in previous versions of bridge makes no sense at the Beta stage, as it interupts a clean migration back to existing workflow.
I would also question the value in not preserving the existing file associations in prior versions of bridge in the final CS6 release, as there are cases when it might be desirable to go back to a previous version of CS, in which case opening that version of bridge and launching directly into the prior versions of CS is very desirable.
Is there anyway to quickly restore the previous associations in CS4/CS5 bridge and be sure that they are exactly the same as prior to the CS6 beta install ?Sorry for the noise. I misunderstood your depth of knowlege and what you had tried. I also committed the sin of not testing the procedure all the way through because I did not want to change the association on my computer. I get the same behavior.
Guess for .jpg
Registry shows for .jpg:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserCho ice Progid = Applications\Photoshop.exe
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\Photoshop.exe\shell\open\command (Default) = "C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Photoshop.exe" "%1"
UserChoice seems to be added when I made the association choice. Note that it points into Applications with a non-version specific Photoshop.exe. Within HKLM\....\Applications there is only one Photoshop.exe -- no version -- and that entry points to CS6.
I believe that explains why the browsed to association is CS6. It does not explain why it would be set up that way. Probably has something to do with Windows special handling of certain file extensions. Beyond my depth and tells me I am not going to find a solution. -
What is the recommended way to handle mouse click events for custom nodes that subclass Panes?
Hi,
I have created a custom node that is a StackPane containing a Label on top of a Polygon.
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;
public class CustomHexagon extends StackPane {
private Polygon hexagon;
private Label overlayText;
public CustomHexagon( String text, double... points ) {
this.hexagon = new Polygon( points );
this.overlayText = new Label( text );
overlayText.setStyle( "-fx-font-weight: bold;" );
hexagon.setStroke( Color.GREEN );
hexagon.setStrokeWidth( 5.0 );
hexagon.setFill( Color.WHITE );
this.getChildren().addAll( hexagon, overlayText );
// Lays out the node where it should be according to the points provided for the Polygon.
this.setLayoutX( points[0] - getLayoutBounds().getMinX() );
this.setLayoutY( points[1] - getLayoutBounds().getMinY() );
// Show the border of the StackPane.
this.setStyle( "-fx-border-color: black; -fx-border-width: 1; -fx-border-style: dashed;");
public String getOverlayText() {
return overlayText.getText();
I want to display a tesselation of these custom hexagons. Because a CustomHexagon is a StackPane, not a Polygon, MouseClick events can be picked up when the mouse is clicked outside of the stroke of the hexagon but still within the StackPane (which takes up a rectangle larger than the hexagon). The following program demonstrates this.
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
Group root = new Group();
CustomHexagon[] hexagons = {
new CustomHexagon( "00", 10.0, 10.0, 30.0, 10.0, 40.0, 27.3205080756, 30.0, 44.6410161512, 10.0, 44.6410161512, 0.0, 27.3205080756 ),
new CustomHexagon( "01", 70.0, 10.0, 90.0, 10.0, 100.0, 27.3205080756, 90.0, 44.6410161512, 70.0, 44.6410161512, 60.0, 27.3205080756 ),
new CustomHexagon( "02", 130.0, 10.0, 150.0, 10.0, 160.0, 27.3205080756, 150.0, 44.6410161512, 130.0, 44.6410161512, 120.0, 27.3205080756 ),
new CustomHexagon( "03", 190.0, 10.0, 210.0, 10.0, 220.0, 27.3205080756, 210.0, 44.6410161512, 190.0, 44.6410161512, 180.0, 27.3205080756 ),
new CustomHexagon( "04", 250.0, 10.0, 270.0, 10.0, 280.0, 27.3205080756, 270.0, 44.6410161512, 250.0, 44.6410161512, 240.0, 27.3205080756 ),
new CustomHexagon( "10", 40.0, 27.3205080756, 60.0, 27.3205080756, 70.0, 44.6410161512, 60.0, 61.961524226799995, 40.0, 61.961524226799995, 30.0, 44.6410161512 ),
new CustomHexagon( "11", 100.0, 27.3205080756, 120.0, 27.3205080756, 130.0, 44.6410161512, 120.0, 61.961524226799995, 100.0, 61.961524226799995, 90.0, 44.6410161512 ),
new CustomHexagon( "12", 160.0, 27.3205080756, 180.0, 27.3205080756, 190.0, 44.6410161512, 180.0, 61.961524226799995, 160.0, 61.961524226799995, 150.0, 44.6410161512 ),
new CustomHexagon( "13", 220.0, 27.3205080756, 240.0, 27.3205080756, 250.0, 44.6410161512, 240.0, 61.961524226799995, 220.0, 61.961524226799995, 210.0, 44.6410161512 ),
new CustomHexagon( "14", 280.0, 27.3205080756, 300.0, 27.3205080756, 310.0, 44.6410161512, 300.0, 61.961524226799995, 280.0, 61.961524226799995, 270.0, 44.6410161512 ),
new CustomHexagon( "20", 10.0, 44.6410161512, 30.0, 44.6410161512, 40.0, 61.961524226799995, 30.0, 79.2820323024, 10.0, 79.2820323024, 0.0, 61.961524226799995 ),
new CustomHexagon( "21", 70.0, 44.6410161512, 90.0, 44.6410161512, 100.0, 61.961524226799995, 90.0, 79.2820323024, 70.0, 79.2820323024, 60.0, 61.961524226799995 ),
new CustomHexagon( "22", 130.0, 44.6410161512, 150.0, 44.6410161512, 160.0, 61.961524226799995, 150.0, 79.2820323024, 130.0, 79.2820323024, 120.0, 61.961524226799995 ),
new CustomHexagon( "23", 190.0, 44.6410161512, 210.0, 44.6410161512, 220.0, 61.961524226799995, 210.0, 79.2820323024, 190.0, 79.2820323024, 180.0, 61.961524226799995 ),
new CustomHexagon( "24", 250.0, 44.6410161512, 270.0, 44.6410161512, 280.0, 61.961524226799995, 270.0, 79.2820323024, 250.0, 79.2820323024, 240.0, 61.961524226799995 ),
new CustomHexagon( "30", 40.0, 61.961524226799995, 60.0, 61.961524226799995, 70.0, 79.2820323024, 60.0, 96.602540378, 40.0, 96.602540378, 30.0, 79.2820323024 ),
new CustomHexagon( "31", 100.0, 61.961524226799995, 120.0, 61.961524226799995, 130.0, 79.2820323024, 120.0, 96.602540378, 100.0, 96.602540378, 90.0, 79.2820323024 ),
new CustomHexagon( "32", 160.0, 61.961524226799995, 180.0, 61.961524226799995, 190.0, 79.2820323024, 180.0, 96.602540378, 160.0, 96.602540378, 150.0, 79.2820323024 ),
new CustomHexagon( "33", 220.0, 61.961524226799995, 240.0, 61.961524226799995, 250.0, 79.2820323024, 240.0, 96.602540378, 220.0, 96.602540378, 210.0, 79.2820323024 ),
new CustomHexagon( "34", 280.0, 61.961524226799995, 300.0, 61.961524226799995, 310.0, 79.2820323024, 300.0, 96.602540378, 280.0, 96.602540378, 270.0, 79.2820323024 ),
new CustomHexagon( "40", 10.0, 79.2820323024, 30.0, 79.2820323024, 40.0, 96.602540378, 30.0, 113.9230484536, 10.0, 113.9230484536, 0.0, 96.602540378 ),
new CustomHexagon( "41", 70.0, 79.2820323024, 90.0, 79.2820323024, 100.0, 96.602540378, 90.0, 113.9230484536, 70.0, 113.9230484536, 60.0, 96.602540378 ),
new CustomHexagon( "42", 130.0, 79.2820323024, 150.0, 79.2820323024, 160.0, 96.602540378, 150.0, 113.9230484536, 130.0, 113.9230484536, 120.0, 96.602540378 ),
new CustomHexagon( "43", 190.0, 79.2820323024, 210.0, 79.2820323024, 220.0, 96.602540378, 210.0, 113.9230484536, 190.0, 113.9230484536, 180.0, 96.602540378 ),
new CustomHexagon( "44", 250.0, 79.2820323024, 270.0, 79.2820323024, 280.0, 96.602540378, 270.0, 113.9230484536, 250.0, 113.9230484536, 240.0, 96.602540378 )
EventHandler<MouseEvent> mouseClickedHandler = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
CustomHexagon h = (CustomHexagon) t.getSource();
System.out.println( h.getOverlayText() );
for ( CustomHexagon hexagon : hexagons ) {
hexagon.setOnMouseClicked( mouseClickedHandler );
root.getChildren().addAll( hexagons );
Scene scene = new Scene(root, 400, 400);
primaryStage.setTitle("Example");
primaryStage.setScene(scene);
primaryStage.show();
public static void main(String[] args) {
launch(args);
After running this program, when one clicks within the intersection of two StackPanes (borders shown by dashed lines), the target of the mouse click event will be the StackPane on top as determined by the order in which they were added to their parent.
This is a problem because there is only a small "T" shaped area within each hexagon that when clicked will target that hexagon with an event, rather than adjacent nodes.
I would appreciate any reccomendations to solve this problem.
Thanks,
James GillerHello, this is an evergreen. Just call setPickOnBounds(false) on the CustomHexagon.
An issue tracking this problem is open here: https://javafx-jira.kenai.com/browse/RT-17024 -
Click events are not working properly in Firefox 18
if some nested html structure and css, click events and event delegation stops working
example:
http://jsfiddle.net/dmitrismirnov/kSYqd/A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
*http://forums.mozillazine.org/viewforum.php?f=25
The helpers at that forum are more knowledgeable about web development issues.<br>
You need to register at the MozillaZine forum site in order to post at that forum. -
Possible bug - Missing click event when handling change event
Using Flex 4.5 SDK, I have a spark ComboBox and a Button next to it for applying a filter according to ComboBox selection.
I listen to both the ComboBox's change event & the Button's click event (for different functions).
When I manually delete the ComboBox text value from its TextInput (i.e. changing selected index to -1) and immediately click on the Button,
the click event-handler function is not being called and only the ComboBox's change event-handler function is executed.
(Selecting a value from the ComboBox's list and clicking on the button triggers both methods on the right order.)
There's also a state definition for the module, but it isn't being changed during these operations...
Is this a bug or a correct behavior? Am I missing something here?
Any workaround suggestions?
(I thought of listening also to mouse-down or mouse-up on the button instead, but haven't tried it yet...)
*** UPDATE ***
When using the Button's mouseDown event the behavior is as expected, so there's a simple workaround.
However, it seems to me like there's a bug with the Button's click event listener or something...
*** UPDATE #2 ***
I created a test application for that and couldn't reproduce the problem.
Then I figured out the problem and solved it.
It's a bit emmbarrasing, but I actually disabled the button (enabled=false) as in a child method of the change handling code...
(If there is no value, don't allow applying the filter - It makes sense! )
Anyway... No issue after all.
However, I choose to leave this post (and not delete it) as an example of identifying and resolving a strange behavior in a complex application.There's no need.
Please read the section UPDATE #2. -
Hi All!
In Good issue I have create One Button and in click event I call one function, but my problem when click this button it call my function 2 times. Please help me fix this problem, my code below:
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
If ((pVal.FormType = 720 And pVal.EventType <> SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And (pVal.Before_Action = True)) Then
oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
If ((pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD) And (pVal.Before_Action = True)) Then
oItem = oForm.Items.Item("2")
oNewItem = oForm.Items.Add("MyBtnP", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
oNewItem.Top = oItem.Top
oNewItem.Height = oItem.Height
oNewItem.Width = oItem.Width + 5
oNewItem.Left = oItem.Left + oItem.Width + 5
oButton = oNewItem.Specific
oNewItem.Visible = True
oButton.Caption = "Fixed Asset"
End If
Select Case pVal.ItemUID
Case "MyBtnP"
If SAPbouiCOM.BoEventTypes.et_CLICK Then
Try
oMatrix = oForm.Items.Item("13").Specific
colItemCode = oMatrix.Columns.Item("1")
Dim Row As Integer = oMatrix.RowCount
For i As Integer = 1 To Row
oEditItemCode = colItemCode.Cells.Item(i).Specific
If oEditItemCode.Value.ToString() <> "" Then
AssetMaster_Add(oEditItemCode.Value.Trim())
End If
Next
Me.SBO_Application.SetStatusBarMessage("Inserted Fixed Asset Successfully.", SAPbouiCOM.BoMessageTime.bmt_Short, False)
Exit Sub
Catch ex As Exception
End Try
End If
End Select
End If
End SubHi Tao,
1. use et_ITEM_PRESSED instead of et_CLICK and combine it with BeforeAction:
If SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED and pval.BeforeAction = False Then
2. generally i recommend you to use BeforeAction instead of the old Before_Action (deprecated)
i saw that in et_FORM_LOAD in top of your code
lg David -
Sharepoint 2010 Custom Visual Webpart button click event firing on page refresh
I have developed a Visual Webpart to create a list in SP using vs2010 and the button click event I have written the list create method. If I click the button list is created successfully. And I refresh the page again list is creating(Again button
click event is triggering).please help me to solve the issue.
protected void Button1_Click(object sender,
EventArgs e)
SPWeb web
= SPContext.Current.Web;
//SPList list=web.Lists["Auto"];
SPList list
= web.Lists[DropDownList2.SelectedItem.Text];
if
(string.IsNullOrEmpty(TextBox1.Text)
|| string.IsNullOrEmpty(DropDownList1.Text))
Label4.Text =
"Fields Are Empty";
else
if (DropDownList1.SelectedItem.Text
== "Single line of Text")
list.Fields.Add(TextBox1.Text,
SPFieldType.Text,
true);
SPView viewname = list.Views["All Items"];
viewname.ViewFields.Add(TextBox1.Text);
//viewname.Update();
list.Update();
Label4.Text =
"Field Created Successfully";
TextBox1.Text =
string.Empty;
// Label4.Text = string.Empty;Hi,
This is because the request is sent to the server when you refresh the page.
A workaround for this is that we can “provide a refresh link that redirects to the same page (or if you have some action causing the refresh programmatically, you could just
redirect to the page after that, with Response.Redirect)
so that page is requested by the browser (with GET method, default with hyperlinks)”.
More information:
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/45648b39-1229-405c-ac9e-60eb82905982/click-event-getting-fired-on-page-refresh
Or we can use the Session to save a value which used as a flag for us to check whether it is a page refresh and perform accordingly.
http://www.codeproject.com/Articles/28099/Refresh-Page-Issue-in-ASP-Net
http://www.codeproject.com/Articles/10240/Detecting-Page-Refresh
Thanks
Patrick Liang
TechNet Community Support -
I have tried out the code in this article in ASP.Net web forms with c# and javascript.
I am using Ajax to call the C# from Javascript and load the data from database.
I have used following article to show the pushpins and there infoboxes.
http://blogs.msdn.com/b/rbrundritt/archive/2013/11/08/multiple-pushpins-and-infoboxes-in-bing-maps-v7.aspx?CommentPosted=true#commentmessage
My code works great on IE 11 , when I have compatibility mode on,
but when compatibility mode is off, the mouse click event is not being received by the Javascript function.
Is this expected behavior of bing maps, Are there any workarounds for this problem?
Thanks
NateHi Ricky, I have tried using Chrome and I see the same issue. The mouse events are not being captured.
Here is my code
<%@ Page Title="" Language="C#" MasterPageFile="~/Maps.Master" AutoEventWireup="true" CodeBehind="BingMaps.aspx.cs" Inherits="MyMaps.secure.BingMaps" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderBody" runat="server" >
<asp:ScriptManager ID="ScriptManager" runat="server"
EnablePageMethods="true" />
<div id="MapHolder" style="; width:1000px; height:800px; " />
<asp:Literal ID="Literal1" runat="server">
</asp:Literal>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptSection" runat="server">
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0">
</script>
<script type="text/javascript" >
var map = null, infobox, dataLayer;
$(document).ready(function () {
GetMap();
function GetMap() {
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("MapHolder"),
{ credentials: "lincensekey", zoom: 2 });
dataLayer = new Microsoft.Maps.EntityCollection();
map.entities.push(dataLayer);
var infoboxLayer = new Microsoft.Maps.EntityCollection();
map.entities.push(infoboxLayer);
infobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { visible: false, offset: new Microsoft.Maps.Point(0, 20) });
infoboxLayer.push(infobox);
PageMethods.GetLocations(RequestCompletedCallback, RequestFailedCallback);
function AddData(MapPoints) {
for (var i = 0, len = MapPoints.length; i < len; ++i)
var pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(parseFloat(MapPoints[i].lat),parseFloat(MapPoints[i].lon))
icon: MapPoints[i].group,
height: 50, width: 60, text: MapPoints[i].city
pushpin.Title = MapPoints[i].name;
pushpin.description = MapPoints[i].desc;
Microsoft.Maps.Events.addHandler(pushpin, 'click', displayInfobox);
dataLayer.push(pushpin);
function displayInfobox(e) {
if (e.targetType == 'pushpin') {
infobox.setLocation(e.target.getLocation());
infobox.setOptions({ visible: true, title: e.target.Title, description: e.target.description });
function RequestCompletedCallback(result) {
result = eval(result);
AddData(result);
function RequestFailedCallback(error) {
var stackTrace = error.get_stackTrace();
var message = error.get_message();
var statusCode = error.get_statusCode();
var exceptionType = error.get_exceptionType();
var timedout = error.get_timedOut();
alert("Stack Trace: " + stackTrace + "<br/>" +
"Service Error: " + message + "<br/>" +
"Status Code: " + statusCode + "<br/>" +
"Exception Type: " + exceptionType + "<br/>" +
"Timedout: " + timedout);
Maybe you are looking for
-
No sound from TV when using HDMI from HP Envy Ultrabook4 despite downloading drivers
Problem: When using an HDMI cord from my HP Envy Touchsmart Ultrabook 4 (4-1105dx)to connect to my TV to view movies, the video appears on my TV screen, but there is NO sound from the TV. Instead the sound comes from my lap top. Troubleshooting: I ha
-
Need urgent help on mailing lable report in group above style
Hi I need to prepare a report on reports 6i in mailing lable style based on group above style (multiple levels) e.g. yellow page directory. can anybody help me. rgds
-
Searching for a monitor icc profile for a Satellite M60-139
i'm a grafic-designer useing a Satellite M60-139 - and therefor i need a color-profile for my Satellite M60-139-display - has anybody an idea where from i can get one?
-
Getting The message Download Error in creative cloud
I keepgetting this error everytime i try to acces the apps in Creative Cloud. I need to reinstall Premiere, and Im now stuck without getting any work done. I really regret upgrading to Creative Cloud. All the software seemed to work better before:-(
-
I've got a Mac Mini (1.83 Core 2 Duo) running 10.6.8. Stock hard drive. Upgraded the RAM a couple of years ago, and haven't had any issues with it, until recently. It is always plugged into a UPS. This past weekend, we decided to rearrange some of th