News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
How to bind a key event for widget?
Author Message
mikshaw
Senior Member
****


Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: How to bind a key event for widget?

Although I'm not sure how well this would work for your needs, if at all, you could try using decimal codes to display the Chinese characters. It isn't ideal, of course, since it will not translate to other machines that don't have the exact font, and without some special magic it is probably useful only for static strings.

Here is a script that will display 256 characters available in the FL_SCREEN font. You'll need to add a set_font line to get your desired font:
Fl:set_font(fltk.FL_SCREEN,"my_font_name")
Optionally change bro:textfont() to a different constant.

EDIT: Then again, maybe just changing the font would provide the same level of usefulness/uselessness

Code:
odd=nil
ww=500; wh=350
win=fltk:Fl_Window(ww,wh,"decimal codes")
bro=fltk:Fl_Browser(10,10,ww/2-20,wh-20)
bro:textfont(fltk.FL_SCREEN)
for i=0,255 do
if i<10 then t="  " elseif i<100 then t=" " else t="" end
if odd then odd=nil; col="@B52@." else odd=1; col="" end
bro:add(col..t..i.."\t"..string.format('%c',i))
end
box=fltk:Fl_Multiline_Output(ww/2,10,ww/2-10,wh-20)
box:textsize(12)
box:set_output()
box:value([[
When including an escaped string of
1, 2, or 3 decimals as part of a Lua
string, those decimals will be read
as the character matching that code.
For example, \64 shows '@' and \10 is
a newline character on systems that
use ASCII:97

In this particular demo, the lines in
the browser were added programatically
rather than being provided as a full
string. Concatenating an escape character
to the string it is intended to escape
is seemingly impossible, but you can get
the same result with string.format:
string.format('%c',number)

Results may vary depending on your
system's configuration or chosen font.
]])
win:show()
Fl:run()

This post was last modified: 09-15-2008 11:44 PM by mikshaw.

09-15-2008 11:39 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
RE: How to bind a key event for widget? - mikshaw - 09-15-2008 11:39 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: