Make new dlg windows mouse position or somewhere specific - photoshop-script

I'm a beginner, I'm trying to match the new created dlg windows to match the position of my mouse or at least somewhere specific, can anyone help?
var dlg = new Window("dialog",[100,495,300,540]);
Tried but look like this is not working.

If you are after a window that's 220 x 45 then I think you want:
var dialog = new Window("dialog");
dialog.text = "Dialog";
dialog.preferredSize.width = 200;
dialog.preferredSize.height = 45;
dialog.show();
Position the window - I'm not so sure about that. A few versions ago any dialog or windows were default to the top left. And you had to use var win = new Window(dlg,'My dialog window'); win.center(); to put them in the centre. It may be possible to position them at exact cooridinates.
However...
Two things that will make your life much easier is the Photoshop scriptUI guide
and Joonas Pääkkö's ScriptUI Dialog Builder. The latter will do a lot of teh heavy lifting for you. You're welcome.

Related

navigateToURL AS3 does nothing on Google Chrome only in my computer

I'm facing a strange behavior of flash Player, on my iMac, running OSX 10.9.2, and Chrome 33.0.1750.146 with Flash Player 12.0.0.70.
I use the following function, to open a page and post to it some jpg data. It worked bofore on my iMac. I can't remember when it stopped working. It is working well on Safari.
On other computers I have, including a Macbook, that runs same chrome and same flash player version, it is also working as expected. So, it sounds crazy.
private function SharePicture(evt:MouseEvent):void
{
var bit:BitmapData = new BitmapData(cena.width, cena.height);
var shiftOrigin:Matrix = new Matrix();
shiftOrigin.translate(-cena.x,-cena.y);
bit.draw(stage, shiftOrigin);
var jpgEncoder:JPGEncoder = new JPGEncoder(95);
var jpgStream:ByteArray = jpgEncoder.encode(bit);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("some-page.php");
jpgURLRequest.requestHeaders.push(header);
//percentLoaded_txt.visible=true;
//percentLoaded_txt.text = processando;
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
navigateToURL(jpgURLRequest, "");
}
I already completely removed Google Chrome and reinstalled again, and no way, to make this code work.
You can try it by yourself, by accessing the following page:
http://www.scrapee.net/en/photo-wall-collage.htm - Just access it, and blick "Save Photo" button on the bottom.
Have anyone an ideal about what is causing this?
Thanks.
navigateToURL takes 2 parameters. The second one, in your case empty string, is the target, where this new window will be open. Possible values are: "_blank"(new window/tab), "_self" (same window/tab) and two others if you work with frames(not flash frames): "_top" and "_parent". For more info:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/package.html
If you don't pass anything as argument, default behavior is _blank, but in your case, you're passing a string, an empty string, and this could be the problem ...

Wide Tile Windows Phone 7.1 using MangoPollo

I have a Windows Phone 7.1 app and I want to include a wide iconic tile. I found a library called MangoPollo:
http://mangopollo.codeplex.com/
I found this code within:
var tile = ShellTile.ActiveTiles.FirstOrDefault();
if (tile != null)
{
var tileData = new FlipTileData();
tileData.Title = "Start Debugging";
tileData.BackContent = "switch to windows phone, we've got candy";
tileData.BackgroundImage = new Uri("Assets/tileBackground.png", UriKind.Relative);
tileData.BackBackgroundImage = new Uri("Assets/tileBackBackground.png", UriKind.Relative);
tileData.WideBackContent = "switch to windows phone, we've got candy";
tileData.WideBackgroundImage = new Uri("Assets/wideTileBackground.png", UriKind.Relative);
tileData.WideBackBackgroundImage = new Uri("Assets/wideTileBackBackground.png", UriKind.Relative);
tile.Update(tileData);
}
The problem is there isn't any documentation included on Codeplex for the project so I'm not sure where to insert this code (i.e. which function) to change the tile size from normal to wide.
Another way of creating Wide Tile in Windows Phone 7. Tested it and it works.
Check this out.
http://www.supersmithbros.com/index.php/latest-news/93-how-to-create-a-wp8-wide-tile-in-wp7-xna
You may call it where you want and there is no code to change tile at the user screen, because it's not allowed.
If you look in the source code, in the link to MangoPollo which you supplied, the sample code places the tile code in a button click event. So what I would do in your app, is make an option to set up this new tile (settings page, maybe?) and when the user turns this setting on, you would run the code in that event handler.
This way, the code doesn't unnecessarily execute multiple times (as it would if it were in the constructor of a page or in app.xaml.cs).
Hope this helps!
Edit:
Based on your comment then, maybe you can put it in the constructor of your first page. Maybe, then, to prevent the code from executing more than necessary, you could check the existing tile to see if it already has a WideBackgroundImage, and if it doesn't, then set it and call Update() otherwise just continue.

Change the colour of WinJS.UI.BackButton (Win 8.1 back button)

I'm getting started with Windows 8 App development using WinJS. I'm using the Light UI theme but I have set up a darker area on the left of the page (where the black back button is) and the issue is: you can't see the button.
I've trawled through the MSDN pages and the most I could find is how to style a button which doesn't actually explain how to change the colour of an actual asset.
http://msdn.microsoft.com/en-us/library/windows/apps/jj835822.aspx
I've also tried adding: win-ui-light and win-ui-dark classes to the button with no success.
I wondered if someone could point me in the right direction?
Many thanks for your time
Chris
First of all you have to delete the link tag that contain UI css by default and add it to document head , Dynamically.see below code :
var uistyle;
// call when your app load or resume.
function onappopen(){
uistyle = document.createElement('link');
uistyle.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";
uistyle.rel = "stylesheet";
uistyle.id = "UIstyle";
document.head.appendChild(uistyle);}
// call when you want to change UI Style.
function UIstyle(UIbool){
if(UIbool=='light'){ uistyle.href = "//Microsoft.WinJS.2.0/css/ui-light.css";}
else {uistyle.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";}}
Like: UIstyle('light'); for light UI in Windows 8 or "UIstyle()" for dark;
I used the DOM Explorer to find the buttons default values and overwrite them. It was the child element that needed to be overwritten: .win-back

Firefox extension: How can I set the cursor position?

I have a page with possibly several content-editable iframes (editors).
Now I would like to use my custom Firefox extension to do the following:
Setting the cursor to the end (or last HTML element) of the editor the cursor actually is in.
I found many solutions to get the cursor's position, but I need one to set it.
Any suggestions?
XPCOM likely includes such functionality as part of the testing rig. Mochitest at least is capable of this (again, probably though XPCOM).
On the other hand, when a user is on the system this a generally a gross violation of user interaction practices. Be sure you have a good justification for doing it. It may seem convenient but what if they're doing something else whilst using your addon? I usually have various apps open at once, Fx extensions are only part of that. I don't want it taking control of my mouse, EVER.
Is there something wrong with setting the focus? At least that only forces the user's hand at a window level.
It also suspect it make it quite difficult to get past AMO review. You'd have to justify why it was necessary to invoke such low-level functionality. If you interact with a window, for example, the window might be able to affect the input of your functions which in turn control the mouse... and then a random web site has access to the user's window!
Found the solution to my problem myself. This code myself will set the Cursor position to the last Paragraph of my editor:
var frame = window.content.document.getElementsByTagName('iframe')[2];
var win = frame.contentWindow;
var editingSession = Components.classes["#mozilla.org/editor/editingsession;1"].createInstance(Components.interfaces.nsIEditingSession);
var editor = editingSession.getEditorForWindow(win);
selection = window.getSelection();
var body = frame.contentDocument.body;
text = frame.contentDocument.createTextNode(".");
body.lastChild.appendChild(text); // add textnode to be selected
var range = editor.document.createRange();
range.setStartBefore(text);
range.setEndAfter(text);
editor.selection.removeAllRanges();
editor.selection.addRange(range);
body.lastChild.removeChild(text); // remove Child

Firefox XUL textbox: How to scroll to the bottom?

I'm working on a Firefox extension, and I have created a multiline text box. When the user presses a button, I add text to the textbox by using (Javascript) TextBoxElement.value += "More Text";
The problem with this code, is that whenever more text is added, the textbox scrolls all the way to the top. With much testing, I haven't figured out how to make it scroll all the way to the bottom again. For some reason the scrollTop property is always 0, and setting it doesn't effect the scroll bar.
Is there any ways I can set the scroll bar back to the bottom of the text box?
My extension's purpose is to embed a small chat box. I'm using a textbox to store the chat history. Maybe using a textbox isn't the most efficient way, so any other suggestions would be great as well.
Someone on Chatzilla helped me out on this one. Thank You!
Anyway, here is the solution:
var TextBoxElement = <TextBoxElement>;
var ti = document.getAnonymousNodes(TextBoxElement)[0].childNodes[0];
ti.scrollTop=ti.scrollHeight;
The another solution is to move caret to the end of textbox content. Caret is controlled with selectionStart and selectionEnd properties (which can be set or get).
Here is the sample code:
var TextBoxElement = document.getElementById("myTextboxId");
var pos = TextBoxElement.value.length;
TextBoxElement.selectionStart = pos;
TextBoxElement.selectionEnd = pos;

Resources