[Cuis-dev] Mouse Focus

Hilaire Fernandes hilaire at drgeo.eu
Tue Oct 19 12:12:09 PDT 2021

Good idea to inspect the hand!

What I am observing is that, when I press my morph, the inspector shows 
it gets the focus. Once I release the button, the focus is lost.

So I try with button1up event. This time the focus sticks to my morph, 
but then with the mouse I can't select any other morph. I need to show 
the halo of any morph, so my morph looses the focus, then I can select 
any morph then.

There is likely something I don't understand. Likely what I want to use 
is the keyboard focus.

Joined is the code.



Le 19/10/2021 à 15:46, Juan Vuletich via Cuis-dev a écrit :
> Just tried. Opened a WidgetMorph, sent to it
> self setProperty: #handlesMouseDown: toValue: true
> Then I opened an inspector on the hand.
> When I click on the widget, the inspector shows it at ivar 
> 'mouseFocus' in the hand. So, it seems to work OK here.
> Please give instructions in enough detail to reproduce what you are doing.

GNU Dr. Geo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20211019/fa424a61/attachment.htm>
-------------- next part --------------
'From Cuis 5.0 [latest update: #4935] on 19 October 2021 at 9:08:05 pm'!
!classDefinition: #DrGFilePreviewMorph category: 'DrGeo-UI-Widgets'!
ImageMorph subclass: #DrGFilePreviewMorph
	instanceVariableNames: 'file'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'DrGeo-UI-Widgets'!

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/17/2021 10:50:08'!
	^ `Color gray`! !

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/17/2021 10:59:39'!
	^ 2! !

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/17/2021 10:50:13'!
	^ `Color gray`! !

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/16/2021 12:08:44'!
file: aFileEntry
	file _ aFileEntry.
	self image: (Form fromFileEntry: file)! !

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/17/2021 10:27:17'!
	^ Preferences standardMenuFont! !

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/19/2021 20:54:22'!
	^ file baseName capitalized ! !

!DrGFilePreviewMorph methodsFor: 'accessing' stamp: 'hlsf 10/17/2021 10:30:48'!
	^ super minimumExtent + (0 @ (self fontToUse pointSize + 8))! !

!DrGFilePreviewMorph methodsFor: 'drawing' stamp: 'hlsf 10/19/2021 20:54:22'!
drawOn: aCanvas
	| name x y f  nameWidth |
	f _ self fontToUse.
	self hasMouseFocus 
		ifTrue: [borderColor _ Theme current focusIndicator]
		ifFalse: [borderColor _ self defaultBorderColor].
		fillRectangle: self morphLocalBounds
		color: color
		borderWidth: borderWidth
		borderStyleSymbol: #simple
		baseColorForBorder: borderColor.
	super drawOn: aCanvas.
	name _ self imageName.
	nameWidth _ f widthOfString: name		.
	nameWidth > extent x ifTrue: [
		name _ name truncateWithElipsisTo: (name size * extent x / nameWidth) floor - 1	.
		nameWidth _ f widthOfString: name		].
	x _ (extent x - nameWidth) // 2.
	y _ extent y - self fontToUse pointSize - 8.
	aCanvas drawString: name at: x at y font: f color: Color white embossed: true.! !

!DrGFilePreviewMorph methodsFor: 'event handling testing' stamp: 'hlsf 10/17/2021 11:20:59'!
handlesMouseDown: e
	^ true! !

!DrGFilePreviewMorph methodsFor: 'events' stamp: 'hlsf 10/19/2021 20:52:31'!
mouseButton1Up: event localPosition: position
	self hasMouseFocus 
		ifTrue: [event hand releaseMouseFocus: self] 
		ifFalse: [event hand newMouseFocus: self].	
	self redrawNeeded ! !

More information about the Cuis-dev mailing list