. .


Open a Window Where You Want It

May 14, 2010 7:10:42.876

Ever wanted to set a window's opening location programmatically in VisualWorks? It looks harder than it is. As you wend your way through the opening code, it's easy to just throw your hands in the air.

Here's a simple solution (thanks to Travis for this one)

  • Create the window using the UI tools
  • Copy the #windowSpec method (class side) to something else, like #baseWindowSpec
  • Now, create a new #windowSpec method like this:

	"make it open where I want it"

	| spec |
	spec := self baseWindowSpec decodeAsLiteralArray.
	spec window bounds: (100 @ 100 extent: 400 @ 500).
	^spec literalArrayEncoding

Replacing the dimensions, of course, with what you actually want. What does that do? It grabs the spec and manipulates the object directly - which, insofar as the framework allows, is the right thing to do. Anyway, it's a simple way of getting a Window to open where you want it to - enjoy.

Technorati Tags: , ,

posted by James Robertson


Re: Open a Window Where You Want It

[anonymous] May 17, 2010 8:05:28.349

This is useful to me. Thanks for sharing.

 Share Tweet This