1. wxEuphoria Problems
I need to change background color of a window several times during a procedure
if possible. Something like this(though this doesn't work):
procedure change_window()
if seconds<60 then
set_back_color( MyPanel, red )
end if
end procedure
AND
I want to monitor the keyboard for a certain key stroke irregardless of
whether the window has focus.
This is the code I have but the window wants focus for the event to fire.
procedure key_event( atom this, atom event_type, atom id, atom event )
key = get_key_code(event)
end procedure
set_event_handler( MyPanel, get_id(MyPanel), wxEVT_KEY_DOWN ,
routine_id("key_event"))
2. Re: wxEuphoria Problems
Richard Egdahl wrote:
>
> I need to change background color of a window several times during a procedure
> if possible. Something like this(though this doesn't work):
> }}}
<eucode>
> procedure change_window()
> if seconds<60 then
> set_back_color( MyPanel, red )
> end if
> end procedure
> </eucode>
{{{
Take a look at timers. Unless this is during a long processing time? In
that case, you might need to call refresh window, or wxApp_Yield to allow
event processing.
> AND
>
> I want to monitor the keyboard for a certain key stroke irregardless of
> whether the window has focus.
> This is the code I have but the window wants focus for the event to fire.
>
> }}}
<eucode>
> procedure key_event( atom this, atom event_type, atom id, atom event )
> key = get_key_code(event)
> end procedure
>
> set_event_handler( MyPanel, get_id(MyPanel), wxEVT_KEY_DOWN ,
> routine_id("key_event"))
> </eucode>
{{{
Where is the focus? You probably need to set up a handler for wherever
the focus is, because that's where the window manager is going to send
events.
Matt
3. Re: wxEuphoria Problems
- Posted by Richard Egdahl <robotdestiny at hotmail.com>
Nov 02, 2006
-
Last edited Nov 03, 2006
Matt,
Basically, what I am trying to write is a credit timer for a coin op
internet terminal. I want the user to be able to use a browser(where the focus
will be) till the time is up, then it will disable the browser or cover the
screen with the euphoria app or flash animation. I figured I would hardwire one
of
rarely used keys to the switch that accepts the quarter but disable it in the
keyboard- if I have to, I will run the switch to the parallel port.
The background color change is meant to get the user's attention that
their time is ending. I have no problem with the logic portion of the coding-
it is the syntax and capabities that get me.
This is the code I have thus far:
without warning
include wxEuphoria.e
include wxGraphics.e
include wxText.e
include wxTimer.e
atom sec
atom reset
sequence clock
atom key
atom quarter
sec=300
reset=0
clock = "5:00"
key=50
quarter=0
constant
MyFrame = create( wxFrame, {0, -1, "Timer", 500,100, 125, 50,wxSTAY_ON_TOP}),
MyPanel = create( wxPanel, {MyFrame,-1,0,0,125,50}),
TextLabel = create(wxStaticText,{MyPanel,-1,"before the fact",10,10}),
OtherTextLabel = create(wxStaticText,{MyPanel,-1,"Please Insert a
Quarter",10,30}),
Timer = create(wxTimer,{MyFrame,-1}),
red = create( wxColour, {"Red"})
procedure onPaint_MyPanel( atom this, atom event, atom it, atom event_type )
set_label(TextLabel,"after the fact")
wx_puts( this, " ")
end procedure
procedure drawclock()
clock=sprint(floor(sec/60))&":"
if sec-(floor(sec/60)*60)<10 then
clock=clock&"0"
end if
clock=clock&sprint(sec-(floor(sec/60)*60))
if key=126 then
sec=sec+150
key=0
end if
if sec=0 and reset=0 then
reset=1
system("calc.exe",2)
end if
set_label(TextLabel,clock)
if quarter>0 then
quarter=quarter-1
end if
if quarter=0 then
set_label(OtherTextLabel,"Please Insert a Quarter")
end if
end procedure
procedure on_timer( atom this, atom event, atom it ,atom event_type )
if sec>0 then
sec=sec-1
end if
drawclock()
if sec<60 then
set_back_color( MyPanel, red )
end if
end procedure
procedure key_event( atom this, atom event_type, atom id, atom event )
key = get_key_code(event)
if key=126 then
set_label(OtherTextLabel,"Quarter Accepted!")
quarter=3
drawclock()
end if
end procedure
set_event_handler( MyPanel, get_id(MyPanel), wxEVT_PAINT, routine_id(
"onPaint_MyPanel" ))
set_event_handler( MyFrame, -1, wxEVT_TIMER, routine_id("on_timer"))
set_event_handler( MyPanel, get_id(MyPanel), wxEVT_KEY_DOWN ,
routine_id("key_event"))
start_timer( Timer, 1000, 0 )
wxMain( MyFrame )
4. Re: wxEuphoria Problems
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com>
Nov 02, 2006
-
Last edited Nov 03, 2006
Richard Egdahl wrote:
>
> Matt,
> Basically, what I am trying to write is a credit timer for a coin op
> internet terminal. I want the user to be able to use a browser(where the focus
> will be) till the time is up, then it will disable the browser or cover the
>
> screen with the euphoria app or flash animation. I figured I would hardwire
> one of
> rarely used keys to the switch that accepts the quarter but disable it in the
> keyboard- if I have to, I will run the switch to the parallel port.
> The background color change is meant to get the user's attention that
> their time is ending. I have no problem with the logic portion of the coding-
> it is the syntax and capabities that get me.
I think that you might want to use some other mechanism than this. It would
probably be better to get the notification from the switch some other way.
I guess that you just have some sort of coin-op hardware and a computer?
I'm by no means a hardware expert, so I couldn't really say what the best
way would be to communicate between the two.
Matt
5. Re: wxEuphoria Problems
- Posted by Richard Egdahl <robotdestiny at hotmail.com>
Nov 02, 2006
-
Last edited Nov 03, 2006
> I think that you might want to use some other mechanism than this. It would
> probably be better to get the notification from the switch some other way.
> I guess that you just have some sort of coin-op hardware and a computer?
> I'm by no means a hardware expert, so I couldn't really say what the best
> way would be to communicate between the two.
>
> Matt
Matt,
Sorry- I didn't mean to overwhelm you with all the details. I told you
all that to put it in context and I am only asking you about the focus and
background color problems. I have the interface covered- I just need the
window to know that something happened even though it doesn't have the focus.
Maybe like an interupt of sorts.. it doesn't matter to me if it keyboard or one
of the ports.. maybe I can peek the memory location for the keyboard- it
shouldn't
need focus to do that. Now I am just thinking outloud so to speak..Haha
Richard
6. Re: wxEuphoria Problems
- Posted by Jesse Adkins <Tassadar29 at lycos.com>
Nov 02, 2006
-
Last edited Nov 03, 2006
The problem with your background color is that you declared a regular
Euphoria sequence as a wxColor type. You need an RGB sequence (255,255,255).
The sequence you want is {255,0,0}. set_back_color is broken ( Just now
checked ) and thus won't accept a sequence like it should. I'll fix that
in a couple minutes.
Secondly, I think you might be able to use wxEVT_SET_FOCUS it seems.
Also, you might also want to consider changing the value for your key event.
126 happens to be the ~ key, which may not have the desired effect.