Xojo Conferences
XDCMay2019MiamiUSA

Sheets and Drawers (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Re: GIF plugin (no QT) OR plugin from source OR distrib QT for older systems?
Next thread: Affixing a subject line to an email


File handling ideas ???   -   Jan Erik Moström <
  Sheets and Drawers   -   Jay Wooten
   Re: Sheets and Drawers   -   Totte Alm
   Re: Sheets and Drawers   -   Kevin Ballard
    Re: Sheets and Drawers   -   Jay Wooten

Sheets and Drawers
Date: 13.08.03 13:36 (Wed, 13 Aug 2003 08:36:16 -0400)
From: Jay Wooten
What is the best way to pass data to and from a sheet/drawer window?

ie from what I understand the proper way to open them is

s = new mySheetWindow

s.showModalWithin(self)

But, as soon as you show model, control is passed to that window so
there isn't an opportunity to pass in data.

on the other hand, if you do something like

s = new mySheetWindow

s.init("A passed string", self) 'assuming there in an init method in
the sheetwindow

and within the sheet window Init method:

Sub Init( thePassedString as string, thePassedWindow as window )

editfield1.text = thePassedString 'assume there is an editfield in
the window

self.showModalWithin( thePassedWindow )

End Sub

But this doesn't work correctly either - the controls on the sheet
window don't appear to activate properly.

Suggestions would be appreciated.

Jay Wooten, President
Visual Dynamics, Inc. - Authorized Apple Specialist
www.visdyninc.com
321-773-7788 w
321-773-9604 f
----------------
Everything is easier on a Mac!
----------------

Re: Sheets and Drawers
Date: 13.08.03 13:56 (Wed, 13 Aug 2003 14:56:15 +0200)
From: Totte Alm
Hello,

There might be severl correct ways of doing this, and a little
depending on if the sheet is somethbing common, or just for one window
type,

I usually do

dim w as MySheetWindow

w = new SheetWindow(self)
w.ShowTimer.Mode
MySheetWindow is set to Invisible

MySheetWindow(inwin as MyParentWindowType) // <- constructor
parent=inwin <- propety

MySheetWindow.ShowTimer is a timer, mode period0, that has the
following code

Self.FunnyEditField.text=parent.getmytextforeditfield()
...
.....
Self.ShowModalWithin(parent)

// The stuff above is for Windows mostly, as calling win.ShowModal()
and its alikes just seems to put RBApps in a funny state at a random
level of reproducubility (thats why no bugreport)

and upon OK, I do
parent.Setfunnyedittext(Self.FunnyEditField.text)
Self.Close

This used Get/Set methods of the MyParentWindowType for getting and
setting data (which then can have their own checking code for
validation of data)

Hope this made it a little clearer
/ Totte
onsdagen den 13 augusti 2003 kl 14.36 skrev Jay Wooten:

> What is the best way to pass data to and from a sheet/drawer window?
>
> ie from what I understand the proper way to open them is
>
> s = new mySheetWindow
>
> s.showModalWithin(self)
>
> But, as soon as you show model, control is passed to that window so
> there isn't an opportunity to pass in data.
>
> on the other hand, if you do something like
>
> s = new mySheetWindow
>
> s.init("A passed string", self) 'assuming there in an init method
> in the sheetwindow
>
> and within the sheet window Init method:
>
> Sub Init( thePassedString as string, thePassedWindow as window )
>
> editfield1.text = thePassedString 'assume there is an editfield in
> the window
>
> self.showModalWithin( thePassedWindow )
>
> End Sub
>
> But this doesn't work correctly either - the controls on the sheet
> window don't appear to activate properly.
>
> Suggestions would be appreciated.
>
> Jay Wooten, President
> Visual Dynamics, Inc. - Authorized Apple Specialist
> www.visdyninc.com
> 321-773-7788 w
> 321-773-9604 f
> ----------------
> Everything is easier on a Mac!
> ----------------
------------------------------------------------------------------------
--------------------
Give a man a fish and you feed him for a day;
teach him to use the Net and he wont bother you for weeks.
--unknown

Re: Sheets and Drawers
Date: 13.08.03 15:29 (Wed, 13 Aug 2003 09:29:07 -0500)
From: Kevin Ballard
Well, if the drawer is to remain open and pass data back and forth, you
might want to create a property

parent as MyWindow

(where MyWindow is the parent window class) and set it to your window
when you open it. That way the drawer can do stuff to the parent window
as it wants.

For sheets, since they're 1-time things, I assume you want to show it,
then pass data back when they close, right? My favourite trick is a
nifty little routine that shows the sheet synchronously and returns the
data requested when the sheet closes. Here's how you do it:

In the calling code, simply put
Dim mySheet As SheetWindow
mySheet = New SheetWindow
s = mySheet.ShowModalWithin(self)

where s is the value you want to get back from the sheet, and
SheetWindow is the window class that you're trying to display as a
sheet.

In SheetWindow, have the following function:

Function ShowModalWithin(parent As Window) As String
Dim s As String
self.ShowModalWithin parent
s = EditField1.Text
self.Close
Return s
End Function

And the following event:

Function CancelClose() As Boolean
If me.Visible Then
me.Hide
Return True
End If
End Function

Then put an editfield that you want the value from and a button, and in
the button say

Sub Action()
self.Close
End Sub

This, of course, is assuming you're trying to return the text from an
editfield back to your main window. If you need something else (like,
you have 3 buttons, and you want to know which one, assign each an
integer that they set to a window property when you press them, and
have the ShowModalWithin() function return that Integer)

The way this works is you're overloading ShowModalWithin(). When you
call the overloaded function, it calls the default ShowModalWithin()
itself, which pauses code execution. When the button is pressed, the
CancelClose event makes the sheet simply hide itself instead of
actually closing, and returns control back to the ShowModalWithin()
overloaded function. At that point, the function gets the text from the
editfield, closes the window for real, and returns the text (it uses a
local variable because when the window closes, the controls on the
window also destruct, so this ensures that the editfield hasn't been
destroyed by the time I try to take the text from it).

The only issue with this technique is if the user tries to quit the
application while the sheet is showing, they can't (at least, not
without pressing Cmd-Q several times). But then again, most users won't
try to quit while showing a modal sheet. If you want your user to be
able to quit with the sheet open, then you have to implement an
isQuitting boolean as described elsewhere (short synopsis: implement a
FileQuit menuhandler and set the boolean there), and make the
CancelClose for the sheet look like:

Function CancelClose() As Boolean
If me.Visible And Not isQuitting Then
me.Hide
Return True
End If
End Function

HTH,
Kevin

On Wednesday, August 13, 2003, at 07:36 AM, Jay Wooten wrote:

> What is the best way to pass data to and from a sheet/drawer window?
>
> ie from what I understand the proper way to open them is
>
> s = new mySheetWindow
>
> s.showModalWithin(self)
>
> But, as soon as you show model, control is passed to that window so
> there isn't an opportunity to pass in data.
>
> on the other hand, if you do something like
>
> s = new mySheetWindow
>
> s.init("A passed string", self) 'assuming there in an init method
> in the sheetwindow
>
> and within the sheet window Init method:
>
> Sub Init( thePassedString as string, thePassedWindow as window )
>
> editfield1.text = thePassedString 'assume there is an editfield in
> the window
>
> self.showModalWithin( thePassedWindow )
>
> End Sub
>
> But this doesn't work correctly either - the controls on the sheet
> window don't appear to activate properly.

Re: Sheets and Drawers
Date: 17.08.03 16:40 (Sun, 17 Aug 2003 11:40:13 -0400)
From: Jay Wooten
Hey - thanks. It's working much better now. However a new 'feature' has
arisen.

The parent window is metal and I have the exact code you have here.

The sheet displays properly, however, after the sheet drops down, the
parent window 'blinks' one time. Then when you click OK, the sheet
window goes back up and the parent window 'blinks' again.

Really odd.

Any thoughts?

On Wednesday, August 13, 2003, at 10:29 AM, Kevin Ballard wrote:

> Well, if the drawer is to remain open and pass data back and forth,
> you might want to create a property
>
> parent as MyWindow
>
> (where MyWindow is the parent window class) and set it to your window
> when you open it. That way the drawer can do stuff to the parent
> window as it wants.
>
> For sheets, since they're 1-time things, I assume you want to show it,
> then pass data back when they close, right? My favourite trick is a
> nifty little routine that shows the sheet synchronously and returns
> the data requested when the sheet closes. Here's how you do it:
>
> In the calling code, simply put
> Dim mySheet As SheetWindow
> mySheet = New SheetWindow
> s = mySheet.ShowModalWithin(self)
>
> where s is the value you want to get back from the sheet, and
> SheetWindow is the window class that you're trying to display as a
> sheet.
>
> In SheetWindow, have the following function:
>
> Function ShowModalWithin(parent As Window) As String
> Dim s As String
> self.ShowModalWithin parent
> s = EditField1.Text
> self.Close
> Return s
> End Function
>
> And the following event:
>
> Function CancelClose() As Boolean
> If me.Visible Then
> me.Hide
> Return True
> End If
> End Function
>
> Then put an editfield that you want the value from and a button, and
> in the button say
>
> Sub Action()
> self.Close
> End Sub
>
> This, of course, is assuming you're trying to return the text from an
> editfield back to your main window. If you need something else (like,
> you have 3 buttons, and you want to know which one, assign each an
> integer that they set to a window property when you press them, and
> have the ShowModalWithin() function return that Integer)
>
> The way this works is you're overloading ShowModalWithin(). When you
> call the overloaded function, it calls the default ShowModalWithin()
> itself, which pauses code execution. When the button is pressed, the
> CancelClose event makes the sheet simply hide itself instead of
> actually closing, and returns control back to the ShowModalWithin()
> overloaded function. At that point, the function gets the text from
> the editfield, closes the window for real, and returns the text (it
> uses a local variable because when the window closes, the controls on
> the window also destruct, so this ensures that the editfield hasn't
> been destroyed by the time I try to take the text from it).
>
> The only issue with this technique is if the user tries to quit the
> application while the sheet is showing, they can't (at least, not
> without pressing Cmd-Q several times). But then again, most users
> won't try to quit while showing a modal sheet. If you want your user
> to be able to quit with the sheet open, then you have to implement an
> isQuitting boolean as described elsewhere (short synopsis: implement a
> FileQuit menuhandler and set the boolean there), and make the
> CancelClose for the sheet look like:
>
> Function CancelClose() As Boolean
> If me.Visible And Not isQuitting Then
> me.Hide
> Return True
> End If
> End Function
>
> HTH,
> Kevin
>
> On Wednesday, August 13, 2003, at 07:36 AM, Jay Wooten wrote:
>
>> What is the best way to pass data to and from a sheet/drawer window?
>>
>> ie from what I understand the proper way to open them is
>>
>> s = new mySheetWindow
>>
>> s.showModalWithin(self)
>>
>> But, as soon as you show model, control is passed to that window so
>> there isn't an opportunity to pass in data.
>>
>> on the other hand, if you do something like
>>
>> s = new mySheetWindow
>>
>> s.init("A passed string", self) 'assuming there in an init method
>> in the sheetwindow
>>
>> and within the sheet window Init method:
>>
>> Sub Init( thePassedString as string, thePassedWindow as window )
>>
>> editfield1.text = thePassedString 'assume there is an editfield
>> in the window
>>
>> self.showModalWithin( thePassedWindow )
>>
>> End Sub
>>
>> But this doesn't work correctly either - the controls on the sheet
>> window don't appear to activate properly.
>
> --
> Kevin Ballard
> REAL Software, Inc.
> http://www.realsoftware.com
>
> ---
> A searchable archive of this list is available at:
> <http://support.realsoftware.com/listarchives/search.php>
> Unsubscribe or switch delivery mode:
> <http://support.realsoftware.com/listmanager/>

---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>