Focus not returning after dragdrop

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Focus not returning after dragdrop

Post by skindoc4 » Sat Oct 31, 2015 9:24 am

Has anyone else noticed this odd behaviour.

After performing a dragdrop of an image, the screen becomes unresponsive to the mouse. Responsiveness is only restored by clicking the titlebar or another window and then returning to the window where the dragdrop occurred. It is a great nuisance.

The following is in the image's handler.

on dragEnter
set the dragAction to "copy"
end dragEnter

command dragdrop
doDragDrop the long id of me
end dragdrop

-- this code is held elsewhere

command doDragEnter
set the dragAction to "copy"
end doDragEnter

command doDragDrop theImage
put the dragData["files"] into theFile
put url ("binfile:" & theFile) into theImageData

mPlaceImage theImage,theImageData

end doDragDrop

command mPlaceImage thePlaceHolder,theImageData
lock screen
put the width of thePlaceHolder into thePDim
put the left of thePlaceHolder into theLeft
put the top of thePlaceHolder into theTop

set the text of thePlaceHolder to theImageData
put the width of thePlaceHolder into theImageWidth
put the height of thePlaceHolder into theImageHeight

if theImageWidth > theImageHeight then
put thePDim into theNewWidth
put theImageHeight * thePDim/theImageWidth into theNewHeight
else
put thePDim into theNewHeight
put theImageWidth * thePDim/theImageHeight into theNewWidth
end if

set the width of thePlaceHolder to theNewWidth
set the height of thePlaceHolder to theNewHeight
set the left of thePlaceHolder to theLeft
set the top of thePlaceHolder to theTop
unlock screen
end mPlaceImage

Using Livecode 7.1.1 rc2 on a MacAir with El Capitan

Klaus
Posts: 13822
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Focus not returning after dragdrop

Post by Klaus » Sat Oct 31, 2015 2:54 pm

Hi skindoc4,

I think this is correct behaviour!

Other apps also show this, e.g. drag and drop anything from the FInder to an open TextEdti document.
TextEdit will not come into foreground after dropping something onto it, all this happens in the background.

Maybe you can add an AppleScript which will bring your app into the foregound again dorectly after dropping?


Best

Klaus

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Sat Oct 31, 2015 2:58 pm

Hi Klaus

I see it now. Thanks. Applescript sounds like an option. I shall have play.

Cheers

Alex

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Sun Nov 01, 2015 2:35 am

Nothing I have tried so far works. I have to manually click the titlebar to get anything on my sheeted substack to work. Applescript doesn't do it - at least that which I have tried so far. The window just remains hung until I click in the titlebar or in the finder or somewhere other than where I want to click, namely in the window where I have just dragged an image.

I have another problem. The buttons which switch on tools (brush, pencil) do not work in either sheet or modal mode but only in editable window mode??

When I add an image to a patient's notes, I want this to be in a modal modal mode so that when I close the image inserting stack, I return to the text field in the patient's notes. So this gotcha is in the way at the moment.

Any advice gratefully received.

Cheers

Alex

community LC 7.1.1 rc2 on El Capitan

Klaus
Posts: 13822
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Focus not returning after dragdrop

Post by Klaus » Sun Nov 01, 2015 4:55 pm

Hi Alex,
skindoc4 wrote:The buttons which switch on tools (brush, pencil) do not work in either sheet or modal mode but only in editable window mode?
This is exspected and correct behaviour, modal stacks, and sheets are modal "the Mac way", are not editable!
If in development mode you need to open all your stack you want to work on in TOPLEVEL mode!


Best

Klaus

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Sun Nov 01, 2015 11:15 pm

Thanks Klaus

I shall tell you what I want to do. Say I want to describe the distribution of a person's back pain. I want to be able to import a generic outline image of the human body and mark the areas where the patient reports pain, and then move the image into the patient's notes. All this I can do when the stack is the top stack but not as you say when the stack is modal or sheet. The advantage of using modal or sheet is that the stack I am working on stays at the toplevel until I am finished with it which is a much neater solution than having stray windows floating on the desktop.

I found the section in the User Guide which explains all this and yes you are right - only the browse tool is available in other than editable windows. I have an idea which will make it work in a neat fashion. Thanks for your guidance.

Cheers

Alex

Klaus
Posts: 13822
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Focus not returning after dragdrop

Post by Klaus » Mon Nov 02, 2015 1:31 pm

Hi Alex,

just to be sure: YOU are using the LC IDE, but your customers will probably not! (Will they?)

So your users can only do what you let them do via your scripting.
And you can script to let the user do all this even in a modal window, but it's up to you! :D


Best

Klaus

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Mon Nov 02, 2015 10:03 pm

Hi Klaus

I am the only customer since I long ago decided that I preferred being a clinician than a full time supporter of software that I write. I did enough of that when I ran a medical practice with software I wrote in 4D some years ago. But yes I do use a standalone version when I am seeing patients.

So far I have found the same issues in the IDE as in the standalone so I do not quite know what you mean about being able to script the use of the brush and pencil tools in modal/screen/palette windows as I have not found a way.

Cheers

Alex

Klaus
Posts: 13822
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Focus not returning after dragdrop

Post by Klaus » Mon Nov 02, 2015 11:11 pm

Hi Alex,
skindoc4 wrote:...So far I have found the same issues in the IDE as in the standalone so I do not quite know what you mean about being able to script the use of the brush and pencil tools in modal/screen/palette windows as I have not found a way.
it IS possible somehow, that's for sure, but probably not worth the enormous efforts, at least I would not want to do it :D


Best

Klaus

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Mon Nov 02, 2015 11:59 pm

Yes Klaus

Desktop real estate is at a premium on my MacAir which I use in my clinical work so I am pursuing alternative ways of achieving my outcome.

Thanks for all your advice.

Cheers

Alex

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Focus not returning after dragdrop

Post by bn » Tue Nov 03, 2015 2:47 am

Hi Alex,

I thought I give it a try what I understood you wanted to do and made a demo stack that opens a substack as sheet on MacOSX. The substack has an image that you can draw with graphics on, once you are done you can export the image (currently to the main stack)

The stack I used is a slight modifications of
http://livecodeshare.runrev.com/stack/3 ... on-Graphic
an old stack I made.

you can choose the color of the graphic, the line size, transparency of the graphic you use to annotate the image. Use button "topLevel" to get out of sheet mode. Use button "exportToMain" to export an image to the main stack. Use button "setModelImage" to set different images. (currently only one image is stored as custom property of the substack, so the button is actually "useless" but shows how to have different images to annotate).

You can option-click on a graphic to select the graphic and move it with the arrowKeys. Opaque closes the polygon and the background color will be visible (probably not so useful in your case.

I tested in LC 7.1.1 rc1, the stack is in LC 5.5 format. It is a long time since I used sheet, but Livecode is still a bit finicky with sheet, sometimes it took the properties inspector to show the sheet. If that happens close the properties inspector.
You would probably have to adapt the substack to your needs but basically I think it lets you annotate an image.

Kind regards
Bernd
Attachments
theMain.livecode.zip
(15.34 KiB) Downloaded 234 times

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Tue Nov 03, 2015 3:00 am

Hi Bernd

Thanks so much for this. I shall have a play.

Cheers

Alex

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3999
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Focus not returning after dragdrop

Post by bn » Wed Nov 04, 2015 6:41 pm

Hi Alex,
did you see that I attached a stack to the previous message?

Kind regards

Bernd

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Wed Nov 04, 2015 10:33 pm

Actually Bernd I had not seen it - thank you.

Alex

skindoc4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 77
Joined: Mon Jul 07, 2008 1:22 am
Location: Brisbane, Queensland

Re: Focus not returning after dragdrop

Post by skindoc4 » Wed Nov 04, 2015 11:09 pm

Neat. There are clearly a few parts of the language that I need to learn.

Cheers

Alex

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”