[BUG][FIX] Multiple browsers in Scamper

Mark Guzdial guzdial at cc.gatech.edu
Tue Apr 20 15:21:01 UTC 1999


Somewhere along the line, Scamper stopped showing new pages in the same
browser window.  I thought that it used to, but recently, every click opens
a new browser window.  The below code fixes that, on Mac and Linux.

Mark

'From Squeak 2.3 of January 14, 1999 on 19 April 1999 at 11:29:39 am'!

!TextURL methodsFor: 'as yet unclassified' stamp: 'mjg 4/19/1999 11:28'!
actOnClickFor: anObject
	"Do what you can with this URL.  Later a web browser."

	| response m browser |

		"if it's a web browser, tell it to jump"
		anObject model isWebBrowser ifTrue: [
			anObject model jumpToUrl: url.
			^true ].

		"if it's a morph, see if it is contained in a web browser"
		(anObject isKindOf: Morph) ifTrue: [
			m _ anObject.
			[ m ~= nil ] whileTrue: [
				(m isWebBrowser) ifTrue: [
					m  jumpToUrl: url.
					^true ].
				(m hasProperty: #webBrowserView) ifTrue: [
					m model jumpToUrl: url.
					^true ].
				m _ m owner. ]
		].

	"no browser in sight.  ask if we should start a new browser"
	(self confirm: 'open a browser to view this URL?') ifTrue: [
		browser _ Scamper new.
		browser jumpToUrl: url.
		browser openAsMorph.
		^ true ].

	"couldn't display in a browser.  Offer to put up just the source"

	response _ (PopUpMenu labels: 'View web page as source\Cancel' withCRs)
		startUpWithCaption: 'Couldn''t find a web browser.  View
page as source?'.
	response = 1 ifTrue: [HTTPSocket httpShowPage: url].
	^ true! !

--------------------------
Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280
(404) 894-5618 : Fax (404) 894-0673 : guzdial at cc.gatech.edu
http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html





More information about the Squeak-dev mailing list