1. Problem with using ALT keys and/or CTRL keys with wxEuphoria

/* Preliminary information – just for understanding Euphoria version 4.0.5 Wxeuphoria version 16 Demo program: catch_keys.exw Modified by me to create completely mirrored Hindi phonetic alphabet using English alphabet to create the real Hindi (Devnagari) characters in Unicode at hex E000 (private area). Devnagari alphabet is arranged as 4 similar character followed by its nasal character – groups of 5. Example: क ख ग घ have the English sounds k kh g gh respectively. Example: प फ ब भ have the English sounds p ph b bh respectively. Counting the Devnagari alphabet and its set of 9 vowel sounds and vowel attachments, I need about 50 characters. However, I also need half characters, as conjoint sounds in Devnagari us half characters. Example: in “sun” सन the full “s” character is there, but in “sweater” - the “sw” is represented as “ स्व ” - note the half “स” followed by the full “ व “ character I am using the lower case alphabet of English for “k and g” ( क ग )in the above example I am using the upper case (shifted) alphabet of English for “kh and gh” ( ख घ )in the above example The position is phonetically same as ASCII + E000 (decimal 57,344)

    integer HindiLoc=57344 -- Private area E000 

For the alphabet I have taken up locations 57,344 + 65 to 57,344 + 90 and 57,344 + 97 to 57,344 + 122 In the demo program, I add 57,344 to the keyIs

	keyIs = get_key_code( event )  
              keyIs = keyIs + Hindiloc 

IT WORKS FINE. However my half characters and vowel attachments are in the next 128 bytes, i.e. at HindiLoc + 128 Example: the character “s” (Ascii 115), which in Devnagari is “ स “ (my Devnagari 57,344 + 115) has its half “s” as in “ स्व ” at 57,344 + 128 + 115

MY PROBLEM: I can reach these extra two rows of 32 (or rather 26 ignoring the other characters) using the Tab key or F11 key

    integer HindiLoc=57344 -- Private area E000 
 
integer f11k = 0 – initialize the F11 flag  
integer tabk = 0 -- or the tab key flag 
--- later  
elsif keyIs = WXK_F11 then -- changing 
     f11k = 1 
elsif keyIs = WXK_TAB then – changing 
    tabk = 1 
--- later 
 if f11k = 1 then 
     keyIs1 = keyIs1 + 128  
end if 
 if tabk = 1 then 
     keyIs1 = keyIs1 + 128  
end if 
-- This code works very well.   

This code works very well. I can press the Tab key or the F11 key and release it and the flag takes care of taking me to the two 32 character lines 128 bytes away. So I have full key board control over the four 32 character lines (instead of the two available in ASCII (unshifted or shifted) I would like to use the ALT key and/or CTRL ley to take me to the 2 extra lines of 32 characters each. I tried

integer altk = 0 – initialize the Alt key flag or 
integer ctrlk = 0 – initialize the Ctrl key flag 
--- later 
elsif keyIs = WXK_ALT then -- changing 
     altk = 1 
elsif keyIs = WXK_CONTROL then – changing 
    ctrlk = 1 
--- later 
 if altk = 1 then 
     keyIs1 = keyIs1 + 128  
end if 
 if ctrlk = 1 then 
     keyIs1 = keyIs1 + 128  
end if 
 
-- This code DOES NOT WORK.   

IN A NUTSHELL: Normal ASCII characters are accessed by un-shifted or shifted alphabet keys.

Basically, I would like the control over four lines of 32 characters, using the Shift key as in ASCII and the Control key and the Alternate key.

I would also prefer to use these keys to set up flags and not have to keep the key pressed while entering the alphabet key.

I also tried the DOS keyIs = get_key() but that does not work.

In DOS The ALT key is 1032400 and the ctrl key is 1020096, but that too is not accepted once I am in the hands of wxEuphoria.

Please help

new topic     » topic index » view message » categorize

2. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

I think you utilize these additional functions:

KEY_EVENT_ALTDOWN

KEY_EVENT_CONTROLDOWN

Other key events

I wonder if the get_unicode_key() would work for you well, as well... smile

new topic     » goto parent     » topic index » view message » categorize

3. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

euphoric said...

I think you utilize these additional functions:

KEY_EVENT_ALTDOWN

KEY_EVENT_CONTROLDOWN

Other key events

I wonder if the get_unicode_key() would work for you well, as well... smile

I tried those too. I hear a bell. Then the next character does not come though and everything is normal till I press alt key again. I tried these key-event s both from within and outside the program relating to getting one character

new topic     » goto parent     » topic index » view message » categorize

4. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Do you have those functions in your key event procedure?

This is taken from the catch_keys.exw demo:

procedure onKey( atom this, atom event_type, atom id, atom event ) 
integer keyIs, controlDown 
object junk 
	keyIs = get_key_code( event ) 
 
	-- I added this line to the demo 
	?key_event_altdown(event) --<-- THIS WORKS FINE (prints 1 when I have altKey pressed, 0 when not) 
	 
	if keyIs != 27 then 
		if keyIs = 13 then 
			msg[$] = msg[$][1..$-1] 
			msg = append(msg,"_") 
		elsif keyIs = 8 then -- deleting 
			if length(msg[$]) > 1 then 
				msg[$] = msg[$][1..$-2] & "_" 
			else 
				if length(msg) > 1 then 
					msg = msg[1..$-1] 
					msg[$] &= "_" 
				end if 
			end if 
		else 
			msg[$] = msg[$][1..$-1] & keyIs & "_" 
		end if 
		refresh_window( this ) 
	else 
		destroy( typeFrame )  
	end if 
end procedure 
set_event_handler( typeWin, -1, wxEVT_CHAR, routine_id("onKey")) 
new topic     » goto parent     » topic index » view message » categorize

5. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

euphoric said...

Do you have those functions in your key event procedure?

This is taken from the catch_keys.exw demo:

procedure onKey( atom this, atom event_type, atom id, atom event ) 
integer keyIs, controlDown 
object junk 
	keyIs = get_key_code( event ) 
 
	-- I added this line to the demo 
	?key_event_altdown(event) --<-- THIS WORKS FINE (prints 1 when I have altKey pressed, 0 when not) 
	 
	if keyIs != 27 then 
		if keyIs = 13 then 
			msg[$] = msg[$][1..$-1] 
			msg = append(msg,"_") 
		elsif keyIs = 8 then -- deleting 
			if length(msg[$]) > 1 then 
				msg[$] = msg[$][1..$-2] & "_" 
			else 
				if length(msg) > 1 then 
					msg = msg[1..$-1] 
					msg[$] &= "_" 
				end if 
			end if 
		else 
			msg[$] = msg[$][1..$-1] & keyIs & "_" 
		end if 
		refresh_window( this ) 
	else 
		destroy( typeFrame )  
	end if 
end procedure 
set_event_handler( typeWin, -1, wxEVT_CHAR, routine_id("onKey")) 

I will try that line again. I tried it inside and also outside in another key-even routine. You could experiment it in any font that is over 512K characters and use the displacement to 256 for the ASCII substitute and a displacement of 384 (256+128) with Alt key or control key. I WILL try again and report back

new topic     » goto parent     » topic index » view message » categorize

6. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

I tried adding ?key_event_altdown(event) at the exact location you suggested. It does not report anything if I press ALT key. If I press any key with it it does just shows the character as if ALT was not pressed. If there is a solution, in a simple way, like you suggested, I will continue to work in this area. Otherwise I will have to go to the area of WXRICHTEXTATTR WXRICHTEXTCTRL WXRICHTEXTEVENT because WXTEXTATTR WXTEXTATTREX WXTEXTCTRL do not have facilities to trap ALT and CTRL keys

new topic     » goto parent     » topic index » view message » categorize

7. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

To be honest, I would accept my work using the ab key to set up the flag to go 128 characters higher. But somebody said to me that they like to use the TAB key for ordinary writing. I could use F11 or F12 key or any other F key, but they are alittle too far up for comfortable typing. If I want to type,

मेरा भारत अच्छा है I have to use the ALT key (or TAB or F11 key) 6 times, and I really don't think people would like to reach F11, although the TAB key will be tolerated by most. It would be nice to have ALT key for the third 32 characters and Ctrl key for the 4th 32 characters.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

ALT and CTRL keys are most convenient, because they occur on both sides of the keyboard

new topic     » goto parent     » topic index » view message » categorize

9. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Bhupen1277 said...

ALT and CTRL keys are most convenient, because they occur on both sides of the keyboard

Can you post the code you have? Maybe we can figure it out from there.

new topic     » goto parent     » topic index » view message » categorize

10. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

euphoric said...
Bhupen1277 said...

ALT and CTRL keys are most convenient, because they occur on both sides of the keyboard

Can you post the code you have? Maybe we can figure it out from there.

I will do better than that, and give you enough to have a go at it in a realistic way. It will be 2-3 hours before I post it. Many Many thanks for looking at the problem. The problem is not urgent. But I have to complete the Kb/font work so I can get to the next stage of my work

new topic     » goto parent     » topic index » view message » categorize

11. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Euphoric:

I have posted the test TTF and test code. It works with F11 flag or Tab flag, but refuses to do so with Alt flag or Ctrl flag.

http://www.mediafire.com/folder/7rnx1ofa2j862/Catch-Keys Please read the commented items at the bottom of the file

new topic     » goto parent     » topic index » view message » categorize

12. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

I'm not sure if this maintains your exact functionality, but the alt and ctrl keys affect what I type...

procedure onKey( atom this, atom event_type, atom id, atom event ) 
object junk 
integer altKey=0, ctrlKey=0, keyIs 
 
	keyIs = get_key_code( event ) -- unshifted lower case (usually) to understand the applied deviations 
	keyIs1 = keyIs 
	keyIs1 = keyIs1 + EuTestLoc -- using Hex 600 to hex 6FF for testing 
 
keyIs0 = keyIs1 - 32 -- capitals if unshifted entered 
keyIs2 = keyIs0 + 128 -- 3rd alphabet row  (Halves or alternate of capitals ) 
keyIs3 = keyIs1 + 128 -- 4th alphabet row  (halves or alternate of lower case) 
 
	altKey = key_event_altdown(event)  -- this will be 1 if true, 0 if false 
	ctrlKey = key_event_controldown(event)  -- this will be 1 if true, 0 if false 
 
	if keyIs != 27 then 
		if keyIs = 13 then 
			msg[$] = msg[$][1..$-1] 
			msg = append(msg,"_") 
		elsif keyIs = WXK_F11 then -- changing 
		   keyIs1 = keyIs1 + 128  
		elsif keyIs = WXK_TAB then -- changing 
		   keyIs1 = keyIs1 + 128  
		elsif ctrlKey then -- changing 
		   keyIs1 = keyIs1 + 128  
		elsif altKey then -- changing 
		   keyIs1 = keyIs1 + 128  
		end if 
		 
		msg[$] = msg[$][1..$-1] & keyIs1 & "_" 
 
		refresh_window( this ) 
	else 
    	destroy( typeFrame )  
	end if 
end procedure 
set_event_handler( typeWin, -1, wxEVT_CHAR, routine_id("onKey")) 
 
new topic     » goto parent     » topic index » view message » categorize

13. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Thanks a lot. It works well with the test font and using ALT key pressed down. It does not seem to work with Control down. I will test it with the real Indic characters, and report back.

Also I would prefer to press ALT character once and get the real character pressed after it (rather than during the key press) to change. I will work on that.

Thanks again.

new topic     » goto parent     » topic index » view message » categorize

14. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Bhupen1277 said...

Also I would prefer to press ALT character once and get the real character pressed after it (rather than during the key press) to change. I will work on that.

You have to use wxEVT_KEY_DOWN and wxEVT_KEY_UP to detect the movement of these keys. The wxEVT_CHAR event is only for printable characters (hence "char" event).

https://docs.wxwidgets.org/2.8/wx_wxkeyevent.html#wxkeyevent

-Greg

new topic     » goto parent     » topic index » view message » categorize

15. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

ghaberek said...
Bhupen1277 said...

Also I would prefer to press ALT character once and get the real character pressed after it (rather than during the key press) to change. I will work on that.

You have to use wxEVT_KEY_DOWN and wxEVT_KEY_UP to detect the movement of these keys. The wxEVT_CHAR event is only for printable characters (hence "char" event).

https://docs.wxwidgets.org/2.8/wx_wxkeyevent.html#wxkeyevent

-Greg

Thanks a lot, ghaberek, for the information. I changed the exw slightly for the Ctrl down.

-- keyIs1 = keyIs1 + 128 - this line changed   
              keyIs1 = keyIs1 + 128 + 64   

Now the Ctrl down displays correctly in the test file Eutest.ttf I have the changed version and a jpg showing the result in this URL:

http://www.mediafire.com/folder/7rnx1ofa2j862/Catch-Keys

The slightly squashed results in the ALT row are a result of the poor quality character in the test ttf. The extra character at beginning f line 2,3,4 is because I have not yet removed the printing of Enter character.

new topic     » goto parent     » topic index » view message » categorize

16. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

ghaberek: I shall appreciate it if you can throw more light on wxEVT_CHAR_HOOK. Many thanks.

new topic     » goto parent     » topic index » view message » categorize

17. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Bhupen1277 said...

ghaberek: I shall appreciate it if you can throw more light on wxEVT_CHAR_HOOK. Many thanks.

The wxEVT_CHAR_HOOK event is used to propogate wxEVT_CHAR-like events "upwards" from the current control that has focus, so that a top level window (like wxFrame) can handle the events globally.

AFAIK it's a bit of a hack and does not work on all platforms (it might actually be Windows-only). If you want to use it, make sure you include the wxWANTS_CHARS flag in your window style when calling create().

-Greg

new topic     » goto parent     » topic index » view message » categorize

18. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

ghaberek said...
Bhupen1277 said...

ghaberek: I shall appreciate it if you can throw more light on wxEVT_CHAR_HOOK. Many thanks.

The wxEVT_CHAR_HOOK event is used to propogate wxEVT_CHAR-like events "upwards" from the current control that has focus, so that a top level window (like wxFrame) can handle the events globally.

AFAIK it's a bit of a hack and does not work on all platforms (it might actually be Windows-only). If you want to use it, make sure you include the wxWANTS_CHARS flag in your window style when calling create().

-Greg

Another piece of information. With my current setup, I am having problems with two character only under Ctrlkey pressed. Ctrl i and Ctrl m are being trapped internally by wxWidgets. Perhaps I can use wxEVT_CHAR_HOOK to rectify this situation. wxWANTS_CHARS flag is already there in the creation of windows. Currently I am not worried about non-Windows users, as my effort is for the Windows users and eventually for the Android users. BTW, for your information, there already are over 100 single character Fonts for the Hindi Language and over 500 overall single character Fonts for India languages. However, almost all of them invade the programming character keys (shift 0-9) and all the others such as [ ] { } < > / ? etc. Hence this effort. Some go over to the num-pad area which is absent in laptops.

Thanks again.

new topic     » goto parent     » topic index » view message » categorize

19. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

Bhupen1277 said...

Ctrl i and Ctrl m are being trapped internally by wxWidgets. Perhaps I can use wxEVT_CHAR_HOOK to rectify this situation.

In that case yes, this is what wxEVT_CHAR_HOOK is meant for. Make sure you call skip( event ) when processing that event.

Bhupen1277 said...

Currently I am not worried about non-Windows users, as my effort is for the Windows users and eventually for the Android users.

We are an incredibly long way off from running Euphoria on Android. It's not impossible, but there are a lot of hoops to jump through to get there.

Plus, the wxAndroid port is still very immature and there's no guarantee it will ever be up to par with the main-line library.

If your goal is to write a single mobile/desktop cross-platform application, you're better off looking at a web-based solution like Electron or Cordova.

-Greg

new topic     » goto parent     » topic index » view message » categorize

20. Re: Problem with using ALT keys and/or CTRL keys with wxEuphoria

ghaberek said...

We are an incredibly long way off from running Euphoria on Android. It's not impossible, but there are a lot of hoops to jump through to get there.

Plus, the wxAndroid port is still very immature and there's no guarantee it will ever be up to par with the main-line library.

If your goal is to write a single mobile/desktop cross-platform application, you're better off looking at a web-based solution like Electron or Cordova.

-Greg

I like wxEuphoria, and am developing a simple editor using English, Hindi and Gujarati, simultaneously AND interchangeably. All the Indic languages are phonetic, derived from Sanskrit, and in Unicode, the characters are spaced multiple of 128 apart, such that the character m for example, Hindi "म" is exactly 128 * 3 = 384 characters away from the Gujarati "મ" and so on with most of the other Indic languages. So developing for the other Indic fonts will be easy, and transliteration simple. Androids was a thought. You will be surprised to know that literally everybody in India has a mobile phone, and a vast majority of them are Androids. They already have the Indic fonts on the Androids. Mine will just be an addition but with full transliteration capability. When the time comes I will switch platforms. I am a seasoned programmer and languages are not a challenge - "C and C plus plus" ARE a challenge and I avoid them as far as possible!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu