Topic: Mouse Buttons? More then one Window?

1)
Anyone knows how to get mousebutton events?

Tried:
Method OnEvent:Int(event:T_irrSEvent)

If event.getEventType()=EET_Mouse_INPUT_EVENT
   Local MouseButton:Int=event.getmouseeventtype()
      Select MouseButton
          Case EKEY_LButton
          End
      EndSelect
EndIf

blabla..


I get no reaction with EKEY_RButton  and EKEY_MButton.
If i use EKEY_LButton and hit the RIGHT Mouse button, it works.
UH?

2)
How to implement a second window in Win32Example?
Cant get any events if i create a second MaxGUI window.

Re: Mouse Buttons? More then one Window?

' ! Left mouse button was pressed down.
Const EMIE_LMOUSE_PRESSED_DOWN = 0

' ! Right mouse button was pressed down.
Const EMIE_RMOUSE_PRESSED_DOWN=1

' ! Middle mouse button was pressed down.
Const EMIE_MMOUSE_PRESSED_DOWN=2

' ! Left mouse button was Left up.
Const EMIE_LMOUSE_LEFT_UP=3

' ! Right mouse button was Left up.
Const EMIE_RMOUSE_LEFT_UP=4

' ! Middle mouse button was Left up.
Const EMIE_MMOUSE_LEFT_UP=5

' ! The mouse cursor changed its position.
Const EMIE_MOUSE_MOVED=6

' ! The mouse wheel was moved. Use Wheel value in event data To find out 
' ! in what direction And how fast.
Const EMIE_MOUSE_WHEEL=7

Re: Mouse Buttons? More then one Window?

Aaah, sry, EMI is in your docs, i am blind.
Thank you very much.

A last one:
It seems that events in that example only work with Windows created via "Window_Hidden" flag turned on.
Just sitting here and wonder how the heck you could know that and why they must be hidden first:)

Re: Mouse Buttons? More then one Window?

as for 2)
with more then one window opened, MaxGUI Gadgets and MouseButton events work.
So "only" a solution for Key_Input must be found..

Re: Mouse Buttons? More then one Window?

can you type into text boxes and stuff?  so its only key events in Irrlicht that arent working?

6 (edited by Takuan 2006-01-11 18:22:09)

Re: Mouse Buttons? More then one Window?

Yes. Listbox and Textfield on a other Window are okay.
Menu events (called per mouse and keyboard) are okay.

Re: Mouse Buttons? More then one Window?

could you post your event code from your second window?  in order to get events to go back to Irrlicht i had to use the PostEvent() function in the loop using the Default clause of the select...  so essentially if the checking mechanism doesnt process the event, then it uses PostEvent() to pass it on further.

another thought, since its not the same window you may have to manually create a T_irrSEvent instance and pass it to the postEventFromUser() method of T_irrIrrlichtDevice.  also, could you post your key checking statements from your T_irrEventReceiver?

thx.

Re: Mouse Buttons? More then one Window?

Not sure whats ment with key checking statements.
Its the Win32 Example.
All I added:
Global MG_Win_Editor1:Tgadget=CreateWindow:TGadget("Editor.. 1",0,0,112,739,Null,Window_Clientcoords|Window_Titlebar|Window_Resizable|Window_Menu|Window_Hidden)
Global MG_Listbox_Entitys:Tgadget=CreateListBox:TGadget(0,0,105,520,MG_Win_Editor1,0)
Global Testbutton:Tgadget=CreateButton:TGadget("mk",0,680,80,30, MG_Win_Editor1,BUTTON_PUSH)

The second window contains only MaxGUI Gadgets.

If PeekEvent() Then
        PollEvent()
        Select EventID()
                        Case Event_Menuaction
             If EventData()=MG_Pop_Copy Then exit       !!!!!Go ahead, not much to see..
            Case EVENT_WINDOWCLOSE
                Exit
            Case EVENT_GADGETACTION   
                            'If EventSource()=Ok
                                'PostEvent(CreateEvent(EVENT_WINDOWCLOSE,testbutton))
                'End If
            Default
                PostEvent(CreateEvent(EventID()),True)
        End Select
    End If       
   
Wend

As soon the mouse enters the panel (irrlicht window) i am able receive mouse button events.
But no Key_W..

Re: Mouse Buttons? More then one Window?

are you checking with EKEY_ constants (Irrlicht) or KEY_ constants (BMAX)?

10 (edited by Takuan 2006-01-11 19:40:47)

Re: Mouse Buttons? More then one Window?

Its your win32 Example.
Irrlicht: Case EKEY_KEY_W


Method OnEvent:Int(event:T_irrSEvent)
If event.getEventType()=EET_Mouse_INPUT_EVENT
  Local MouseButton:Int=event.getmouseeventtype()
  Select MouseButton
    Case EMIE_LMOUSE_PRESSED_DOWN
    End
  EndSelect
EndIf
       
' check If user presses the key 'W'
If event.getEventType()=EET_KEY_INPUT_EVENT And event.getKeyPressedDown()=False
Local key:Int=event.getKeyInputKey()

Select key
' switch wire frame mode
Case EKEY_KEY_W                       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
box.setMaterialFlag(EMF_WIREFRAME, box.getMaterial(0).getWireframe()=False)
Return True   
EndSelect           
EndIf
Return False
EndMethod


Mouse okay, Key not.
Tried if i could get MaxGUI response but fails:

If PeekEvent() Then
        PollEvent()
        Select EventID()
            Case Event_Keydown   !!!!!!!!!!!!!!!!!!
                Exit     
            Case EVENT_WINDOWCLOSE
                Exit
            Case EVENT_GADGETACTION   
                            'If EventSource()=Ok
                                'PostEvent(CreateEvent(EVENT_WINDOWCLOSE,testbutton))
                'End If
            Default
                PostEvent(CreateEvent(EventID()),True)
        End Select
    End If       
   
Wend

Re: Mouse Buttons? More then one Window?

i think the problem is that while a gadget has focus it is capturing events.  if you change your Default of your second window to:

If EventID()=EVENT_KEYDOWN
    Local event:T_irrSEvent=T_irrSEvent.create()
    event.setEventType(EET_KEY_INPUT_EVENT)
    event.setKeyInputKey(EventData())
    device.postEventFromUser(event)                
EndIf

this will manually post the keystroke to Irrlicht.  you will need a reference to the device on the second window.  you can actually call that from anywhere if you change the EventData() to whatever keystroke you want to push.  obviously you can push any kind of event also just by changing parameters to the T_irrSEvent methods.

HTH

Re: Mouse Buttons? More then one Window?

But how can i post manually Keystrokes if i dont know there are some.
"If EventID()=EVENT_KEYDOWN" never gets true, so how that code would help?


Maybe that makes it more clear:

One window:
Event_Mousedown and Event_Keydown doesnt work.

EET_KEY_INPUT_EVENT works.
EMIE_LMOUSE_PRESSED_DOWN works.
Event_Gadgetaction works.

Two windows(one with a panel as Irrlicht window, one with a button and a listbox):
Event_Mousedown and Event_Keydown doesnt work.
EET_KEY_INPUT_EVENT doesnt work.

EMIE_LMOUSE_PRESSED_DOWN works!!?
Event_Gadgetaction works.


Well, dont want to make you crazy;)