Page 1 of 1

EditorGadget and focus of parent window

Posted: Thu May 02, 2024 4:27 am
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? :?

Re: EditorGadget and focus of parent window

Posted: Thu May 02, 2024 5:31 am
by jacdelad
Code?
Also, I don't think that's a bug...

Re: EditorGadget and focus of parent window

Posted: Wed May 15, 2024 10:45 am
by Fred
Any chance to get a code ?

Re: EditorGadget and focus of parent window

Posted: Tue May 21, 2024 9:36 pm
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

Re: EditorGadget and focus of parent window

Posted: Wed May 22, 2024 1:42 am
by BarryG
I ran it and pressed the arrow keys but nothing happened? Using PureBasic 6.10 (64-bit).

Re: EditorGadget and focus of parent window

Posted: Wed May 22, 2024 4:36 am
by jacdelad
Same here too.

Re: EditorGadget and focus of parent window

Posted: Wed May 22, 2024 4:53 am
by es_91
I am using high contrast mode. Ease of access.

Re: EditorGadget and focus of parent window

Posted: Tue Jun 11, 2024 6:46 pm
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  )
	
;}


Re: EditorGadget and focus of parent window

Posted: Wed Jun 12, 2024 6:17 am
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

Re: EditorGadget and focus of parent window

Posted: Thu Jun 13, 2024 6:35 pm
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()