EditorGadget and focus of parent window

Windows specific forum
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

EditorGadget and focus of parent window

Post by es_91 »

When an arrow key can not access a surrounding position in the editor gadget, the windows blinks up.



This does not happen with the standard Notepad editor.



Why is that? :?
:mrgreen:
User avatar
jacdelad
Addict
Addict
Posts: 2004
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: EditorGadget and focus of parent window

Post by jacdelad »

Code?
Also, I don't think that's a bug...
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: EditorGadget and focus of parent window

Post by Fred »

Any chance to get a code ?
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: EditorGadget and focus of parent window

Post by es_91 »

sorry ... simple as that:

Code: Select all

*window = openWindow ( #pb_any, 0, 0, 600, 300, "Editor", #pb_window_systemMenu)

*editor = editorGadget ( #pb_any, 0, 0, 600, 300 )

setGadgetText ( *editor, "Test text ... use arrows and get the window blinking" )

repeat
	
until waitWindowEvent ( ) = #pb_event_closeWindow
Only when an arrow movement can not be processed into a cursor movement, the window blinks up.


Windows 10 x86 PB 6.1
:mrgreen:
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: EditorGadget and focus of parent window

Post by BarryG »

I ran it and pressed the arrow keys but nothing happened? Using PureBasic 6.10 (64-bit).
User avatar
jacdelad
Addict
Addict
Posts: 2004
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: EditorGadget and focus of parent window

Post by jacdelad »

Same here too.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: EditorGadget and focus of parent window

Post by es_91 »

I am using high contrast mode. Ease of access.
:mrgreen:
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: EditorGadget and focus of parent window

Post by es_91 »

Me, again.


"BLINKING" was a complete mistranslation from me here, sorry !


THIS is what happens:


Image
window having active focus

Image
window without active focus

Code: Select all


;{
	
	openWindow  (  #pb_any,  
	               #null,  
	               #null,  
	               600,  
	               300,  
	               "Use arrow keys to play with the window focus",  
	               #pb_window_systemMenu  |  
	               #pb_window_screenCentered  )
	
	editor  =  editorGadget  (  #pb_any, 
	                            #null,  
	                            #null,  
	                            600,  
	                            300,  
	                            #pb_editor_wordWrap  )
	
	setGadgetText  (  editor,  
	                  "The window will 'jump-over' its focus when "  +  
	                  "you press an arrow key without the editor "  +  
	                  "having any cursor position to go to..."  )
	
	repeat
	until  (  waitWindowEvent  (  )  =  #pb_event_closeWindow  )
	
;}

:mrgreen:
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: EditorGadget and focus of parent window

Post by PeDe »

I have Windows 7 here and can understand your described behavior of the window. I have selected the sound scheme 'No sounds' in the control panel. Apparently this has changed a setting for easier operation, see:

(translations from German:)
-> Control Panel
-> Center for easier operation
-> Use text or visual alternatives to play sound

You can make the title bar or the whole window blink when the cursor can no longer be moved.

Edit: Programs with the control element 'RichEdit20W' or 'RichEdit50W' behave in the same way as e.g. 'Microsoft WordPad', 'SpeedCommander SpeedView'.

Peter
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: EditorGadget and focus of parent window

Post by PeDe »

This sample code can be used to switch off the standard sound. This means that the window title no longer flashes when the function for easier access is activated.

Peter

Code: Select all

EnableExplicit

Interface ITextServices Extends IUnknown
	TxSendMessage.i()
	TxDraw.i()
	TxGetHScroll.i()
	TxGetVScroll.i()
	OnTxSetCursor.i()
	TxQueryHitPoint.i()
	OnTxInPlaceActivate.i()
	OnTxInPlaceDeactivate.i()
	OnTxUIActivate.i()
	OnTxUIDeactivate.i()
	TxGetText.i()
	TxSetText.i()
	TxGetCurTargetX.i()
	TxGetBaseLinePos.i()
	TxGetNaturalSize.i()
	TxGetDropTarget.i()
	OnTxPropertyBitsChange.i(dwMask.l, dwBit.l)
	TxGetCachedSize.i()
EndInterface

#TXTBIT_ALLOWBEEP = $800	; Enable/Disable beeping.
#COMFalse = 0
#COMTrue = ~#COMFalse	; -1


Procedure RichEditBeep(iEditorNr.i, fState.i = #False)
	Protected iLib.i, *IIDTextServices.IID, *sIIDTextServices, iResult.i, iBeepState.i
	Protected *ITextServices.ITextServices, *IRichEditOle.IUnknown

	If fState
		iBeepState = #COMTrue
	Else
		iBeepState = #COMFalse
	EndIf
	
	iResult = SendMessage_(GadgetID(iEditorNr), #EM_GETOLEINTERFACE, 0, @*IRichEditOle)
	If Not iResult
		Debug "Error SendMessage_(#EM_GETOLEINTERFACE)"
	Else
		iLib = OpenLibrary(#PB_Any, "msftedit.dll")
		If iLib
			*IIDTextServices = GetFunction(iLib, "IID_ITextServices")
			If Not *IIDTextServices
				Debug "Error GetFunction() IID_ITextServices"
; 			Else
; 				iResult = StringFromIID_(*IIDTextServices, @*sIIDTextServices)
; 				If Not (iResult = #S_OK)
; 					Debug "Error StringFromIID_()"
; 				Else
; 					Debug "IID_ITextServices: " + PeekS(*sIIDTextServices)	; {8D33F740-CF58-11CE-A89D-00AA006CADC5}
;  					CoTaskMemFree_(*sIIDTextServices)
; 				EndIf
			EndIf
		EndIf
		
		If *IIDTextServices
			iResult = *IRichEditOle\QueryInterface(*IIDTextServices, @*ITextServices)
			*IRichEditOle\Release()
			If Not (iResult = #S_OK)
				Debug "Error QueryInterface() - " + Hex(iResult)
			Else
				*ITextServices\OnTxPropertyBitsChange(#TXTBIT_ALLOWBEEP, iBeepState)
				*ITextServices\Release()
			EndIf
		EndIf

		If iLib
			CloseLibrary(iLib)
		EndIf
	EndIf

EndProcedure


Procedure Main()
	Protected iWindowNr.i, iEditorNr.i
	
	iWindowNr = OpenWindow ( #PB_Any, 0, 0, 600, 300, "Editor", #PB_Window_SystemMenu)
	iEditorNr = EditorGadget ( #PB_Any, 0, 0, 600, 300 )
	
	SetGadgetText (iEditorNr, "Test text ... use arrows and get the window blinking" )
	
	RichEditBeep(iEditorNr, #False)	; Disable Beep.
; 	RichEditBeep(iEditorNr, #True)	; Enable Beep.
	
	SetActiveGadget(iEditorNr)
	
	Repeat
	Until WaitWindowEvent ( ) = #PB_Event_CloseWindow
EndProcedure


Main()

Post Reply