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
jyf1987
Member
***


Posts: 58
Group: Registered
Joined: Jun 2008
Status: Offline
Reputation: 0
Post: #1
RE: How to bind a key event for widget?

thank you very much
when i dont get the answer i use set_event_handler to solver the problem
the code is

Code:
function quit_callback(msg)
   if fltk.fl_choice("Are you sure you want to EXIT ?", "No", "Yes", nil) >= 1 then
      w:hide()
      os.exit()
   end
end

function all_event(event)
  if(Fl:event_key(FL_Enter) and murgaLua.getFltkEventText(event)=="FL_SHORTCUT") then
    msgout:add(msgin:value())
    msgout:bottomline(msgout:size())
    msgin:value("")
  end
end

ww,wh,wt=300,280,"Simple IRC Client - Powered by jyf1987"

w= fltk:Fl_Window(ww,wh,wt)
w:callback(quit_callback)

msgout= fltk:Fl_Browser(5, 5, 290, 240)

msgin= fltk:Fl_Input(5, 250, 290, 25)





w:show()

Fl.set_event_handler(all_event)
Fl:start_event_handler()
Fl:run()


also it's easy to use widget:when(fltk.FL_WHEN_ENTER_KEY_ALWAYS)

here is the new code

Code:
function quit_callback(msg)
   if fltk.fl_choice("Are you sure you want to EXIT ?", "No", "Yes", nil) >= 1 then
      w:hide()
      os.exit()
   end
end

ww,wh,wt=300,280,"Simple IRC Client - Powered by jyf1987"

w= fltk:Fl_Window(ww,wh,wt)
w:callback(quit_callback)

msgout= fltk:Fl_Browser(5, 5, 290, 240)


msgin= fltk:Fl_Input(5, 250, 290, 25)
msgin:callback(
function()
  msgout:add(msgin:value())
  msgout:bottomline(msgout:size())
  msgin:value("")
end
)
msgin:when(fltk.FL_WHEN_ENTER_KEY_ALWAYS)


w:show()

Fl:run()


Cheers
jyf
09-14-2008 12:55 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? - jyf1987 - 09-14-2008 12:55 PM

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

Forum Jump: