ModalStack Fun

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 367
Joined: Mon Jun 10, 2013 1:32 pm

ModalStack Fun

Post by Lagi Pittas » Tue Jun 02, 2015 6:20 pm

Hi

This should be easy :wink:

I have the following code in a button of a mainstack that calls a substack "SUB".
This is the bare bones I have removed from my application where I call a routine in a substack /library and I want the substack to align itself just at the bottom left of the field.
The aligning works perfectly if it's not a modal window , but if called with AS MODAL it centres itself within the calling stack.

I'll go out on a limb here and assume that's by design - but why? And is there any trick to getting a modal box to popup where YOU want?

Code: Select all

on mouseUp
   get AdjacentTo(the long ID of me)
   go to stack "sub" -- AS MODAL
end mouseUp

function AdjacentTo pField
   local lcTarget, lcCallingStack
   local lnRCall, lnRSub
   
   put item 1 of the target into lcTarget
   put the short name of the owner of stack "sub" into lcCallingStack
   
   if pField is not empty then put pField into lcTarget
   
   set  the left of stack "sub" to the left of stack lcCallingStack + the left of lcTarget 
   set the top of stack "sub" to top  of stack lcCallingStack + the bottom of lcTarget + the height of lcTarget
   
   put the right of stack lcCallingStack into lnRCall
   put the right of stack "sub"  into lnRSub
   
   if lnRSub > lnRCall then
      set the left of stack "sub"  to the left of stack "sub" - (lnRSub - lnRCall) - 5
   end if

end AdjacentTo
LC 6.7.5 Maxc OSX Yosemite

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7403
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: ModalStack Fun

Post by jacque » Wed Jun 03, 2015 8:02 pm

The positioning is intentional and meets the guidelines for each OS. Modal windows prevent the user from taking any other actions until it is dismissed, and should appear in a very visible place so that the user can respond. I think that moving it to an off-center location may not alert the user that they need to take action immediately.

Can you tell us why you need a modal window? There may be a better method. There are tricks to force the modal to a different position but it would be better to decide if modal is what you really need.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply