Page 1 of 1

ModalStack Fun

Posted: Tue Jun 02, 2015 6:20 pm
by Lagi Pittas
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

Re: ModalStack Fun

Posted: Wed Jun 03, 2015 8:02 pm
by jacque
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.