I’m developing an application using FXRuby and need to enter text that
has accented letters in it (portuguese texts).
But the controls doesn’t show the accented letters as I type them - just
the corresponding letter without the accent.
I’ve captured SEL_KEYPRESS for a FXText control and I can see that it
“sees” as I type in the key with the accent, and then the key for the
letter I want to have accented.
Here’s an excerpt of the output of the captured event (the relevant
statement here is puts data.text << " (" << data.code.to_s << “)”):
(65505)
< (60)
p (112)
(65505)
(62)
(65505)
I (73)
s (115)
t (116)
o (111)
(32)
(65105)
e (101)
(32)
c (99)
e (101)
r (114)
t (116)
o (111)
(65505)
< (60)
/ (47)
p (112)
(65505)
(62)
letter I want to have accented.
I (73)
t (116)
I know that (65105) is the code for the left shift. (65105) would be the
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
you’ll need to convert your text to utf-8 encoding using Iconv.
Have a look at this (somewhat randomly copied from a Wikipedia
article about the Brazilian sociologist Gilberto Freyre) and the FXRuby
tutorial:
theApp = FXApp.new
text = Iconv.iconv(“utf-8”,“iso-8859-1”,“Interpretação do Brasil”)
p text
theMainWindow = FXMainWindow.new(theApp, text[0])
text2=“O Brasil do futuro não vai ser o que os velhos historiadores
disserem e os de hoje repetem. Vai ser o que Gilberto Freyre disser.
Freyre é um dos gênios de palheta mais rica e iluminante que estas terras
antárticas ainda produziram.”
message = Iconv.iconv(“utf-8”,“iso-8859-1”,text2)
theButton = FXButton.new(theMainWindow, message[0])
theButton.connect(SEL_COMMAND) do |sender, selector, data|
exit
end
Thank you for the hints, but I think I didn’t express myself clearly.
Actually, when the text is presented on the FXText control (coming from
a database), the control shows the accented letters pretty well.
The problem is when I try to insert new text. The application seems to
ignore the keystrokes relative to the accents, accepting just the
following keystroke, which is the actual letter.
I’ve already post this on the FXRuby users list, but they think it’s a
Ruby matter.
I hope somebody could help me with this.
Cheers,
Em Ter, 2008-08-19 Ã s 06:44 +0900, Axel E. escreveu:
message = Iconv.iconv(“utf-8”,“iso-8859-1”,text2)
Best regards,
Axel
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
Thank you for the hints, but I think I didn’t express myself clearly.
Actually, when the text is presented on the FXText control (coming from
a database), the control shows the accented letters pretty well.
The problem is when I try to insert new text. The application seems to
ignore the keystrokes relative to the accents, accepting just the
following keystroke, which is the actual letter.
Dear Angico,
sorry, I misunderstood. You mean that you want to interact dynamically
with
FXRuby in some way, like ask the user some question and have the user’s
answer displayed ?
It seems that depending on what OS you use, you can define a connection
key (on the system,
not in Ruby or FXRuby) so that accent+key are drawn together … see
here for Ubuntu:
To me ( I am not Brazilian or Portuguese) , the problem you are
experiencing is somewhat surprising, as for instance in French or
German, there are special keys that allow you to enter the whole letter
in one go … but the French don’t have the tilde letters ~a and ~o …
maybe general Portuguese language programming forums can help you if the
connection-key hint doesn’t work …
I’d nevertheless like to know if it does.
Em Ter, 2008-08-19 Ã s 07:22 +0900, Axel E. escreveu:
To me ( I am not Brazilian or Portuguese) , the problem you are experiencing is somewhat surprising, as for instance in French or German, there are special keys that allow you to enter the whole letter in one go … but the French don’t have the tilde letters ~a and ~o …
maybe general Portuguese language programming forums can help you if the connection-key hint doesn’t work …
I’d nevertheless like to know if it does.
Best regards,
Axel
Hi, Axel.
I use Ubuntu Linux 8.04. All the applications I have installed on my
system work fine (OpenOffice.org does, JEdit does, Eclipse does,
Evolution does, etc.)
The only one that refuses to “understand” the key combinations is
exactly this one I’m working on: An FXRuby application. Also, as I
already stated, the application can display the text correctly. It just
can’t make the combination.
So, I guess the problem is with Ruby.
The brazilian ABNT2 keyboard has only one special key: ç. The remaining
accented letters must be typed as a combination of a dead key (the
accent) followed by the actual letter key, as in ~a, which gives an ã.
But FXRuby’s controls still don’t accept or understand them.
Regards,
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
not in Ruby or FXRuby) so that accent+key are drawn together … see
I’d nevertheless like to know if it does.
skype: angico00
Dear Angico, dear all,
I have switched my keyboard layout to Brazilian and I can confirm your
FXRuby accent entering troubles.
However, I am not sure whether the missing touch is in the Ruby camp
rather than in FXRuby’s.
I could enter Brazilian accents in the reminder application in the
sample directory of shoes.
This is due to the fact that shoes uses the pango library
(http://www.pango.org/) for internationalization.
Now, on their page, they talk about integration with the GTK2 GUI
toolkit, which, of course, isn’t the
same as FOX, on which FXRuby builds.
As I am not an expert about the intricacies of using pango (or some
equivalent) with Fox/FXRuby,
I am just CC’ing this message to the fxruby list.
Actually, when the text is presented on the FXText control (coming from
a database), the control shows the accented letters pretty well.
The problem is when I try to insert new text. The application seems to
ignore the keystrokes relative to the accents, accepting just the
following keystroke, which is the actual letter.
I’ve already post this on the FXRuby users list, but they think it’s a
Ruby matter.
I checked the FXRuby mailing list archives, and found where you posted
this question on the FXRuby list (around the beginning of last month).
I’m sorry you didn’t get any helpful responses, but I don’t see that
anyone suggested that it was “a Ruby matter”.
It is most likely a FOX-related issue, and has something to do with
how FOX translates (or doesn’t translate) those keypresses before
sending out the SEL_KEYPRESS and SEL_KEYRELEASE messages. FXRuby
doesn’t do any manipulation of those results; it just passes through
whatever the FOX library generates. You might have better luck asking
on the FOX mailing list.