Please, help me inspect Window Events under Linux

Linux specific forum
User avatar
Derlidio
User
User
Posts: 77
Joined: Fri Feb 27, 2004 9:19 pm
Location: SP - Brazil

Please, help me inspect Window Events under Linux

Post by Derlidio »

Yeepy...

When I choose PureBasic in order to make cross platform applications I was aware of some portability issues. I know that if I want the same code running under diferent OS I shall not use specific API calls and avoid any library that doesn't work in both systems. That is not a dificult task becouse the compatibility of functions are all stated at PB documentation and I really do not plan to call specific OS API. If PB is as fast as I think it is, I'll not need those calls :)

I'm testing a full registered version of PB for a couple of weeks and I'm stubbed with a thing I thought should be a simple task. I'm trying to inspect Events comming from a Window. As I said before, I know that the message ID returned for each event might be different under Windows and Linux. The piece of code that follows works fine under WinXP, but does not under Red Hat 8 (I picked a GNU/Linux distro from the tested versions stated at PB Linux Documentation).

I already post something about it at the Beginners forum, but I think the post was misunderstood. The main problem is not related with the way text is displayed, despite of the fact Locate() function seems do not work properly. The first call to Locate() works fine, but the secont does not. Freaky :?:

As a Linux newbie, I can't tell if it is a problem within the distro I choose for or if it is a real PB bug, so I'm posting here and I hope somebody can drop some light at my questions :roll:

Well... the main goal of the code below was to inspect message IDs sent by the system to the window itself. As I could perceive, I can compare the events returned by WaitWindowEvent() with the PB constants (since the CloseWindow Event is working fine), but I could not print them or manage them someway different. Why? Am I doing something wrong? Are events not catch by WaitWindowEvent() in the form of a numeric code that can be held by a Long type variable? Can I print out those values (properly converting them to a string before printing)?

I'm programming Basic-Like languages since a long time ago. Indeed, I've never asked for help on a forum, and I'm very shamed about doing it now, but I have no other way to solve this questions quickly.

I hope some of you can give me some aid on that issue. Indeed, I'll be grateful for any clue. Thanks in advance...

Derlidio

Code: Select all

OpenWindow(0, 0, 0, 320, 200, #PB_Window_SystemMenu|#PB_Window_SizeGadget, "Testing, 1, 2, 3...")

Repeat

    E = WaitWindowEvent()

    If E <> #PB_Event_CloseWindow
 
       X = X + 1

       StartDrawing(WindowOutput())
          FrontColor(0,0,0)
          BackColor(255,255,255)
          Locate(40,50): DrawText("Event: " + StrU(E,#Long) + " Event Count: " + Str(X))
          Locate(40,80): DrawText("Event: " + StrU(E,#Long) + " Event Count: " + Str(X))
       StopDrawing()

       Else

       MessageRequester("Bye Bye", "Leaving...")
       Break

    EndIf
    
ForEver

End
Derlidio Siqueira
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The problem is the WindowOutput() which doesn't work exactly the same on WIndows and Linux. I strongly suggest to use a TextGadget() to display some text instead of writing directly on the window video buffer. Do it solve your problem ?
User avatar
Derlidio
User
User
Posts: 77
Joined: Fri Feb 27, 2004 9:19 pm
Location: SP - Brazil

Please, help me inspect Window Events under Linux

Post by Derlidio »

Yeepy...

Hi Fred. Thanks for your reply, but I'm afraid it doesn't solve my problem. :(

As I said before, the main question envolving this post is not the way information is printed out. I would like very much if 2D Drawing commands works the same way under both OS using WindowOutput(), but if it is not possible and there is a workaround it'll be fine.

The main question is: Can I use the value returned by WaitWindowEvent() in some way different than comparing it with PB constants? I've writed another piece of code, this time using the Console to print out the values returned by WaitWindowEvent() function. As usual, I tested the code under WinXP with no problems at all. By the other side, under Linux it does not work the way I expect. The value of EventID (in the code, the variable "E") always print "0" instead of the value it actually contains.

What kind of value does WaitWindowEvent() return? It is a long right? So, that is what is freaking me out! Why does it work fine to compair the returned Event ID with #PB_Event_CloseWindow and does not with Print(StrU(E,#Long))?

If you run the code below, you'll see that Event Count (the "X" variable) increases each time a Mouse Event ocours inside the "Testing 1, 2, 3..." window, but no Event ID shows up at the console.

I'm sorry if I bothering you insisting in this subject. As I said before, I thought it was a simple task, but it seems to be not. :(

Best Wishes...

Code: Select all

OpenConsole()

PrintN("Starting Event Inspection:")

OpenWindow(0, 0, 0, 320, 200, #PB_Window_SystemMenu|#PB_Window_SizeGadget, "Testing, 1, 2, 3...")

Repeat

    E = WaitWindowEvent()

    If E <> #PB_Event_CloseWindow
       X = X + 1
       PrintN ("Event: " + StrU(E,#Long) + " Event Count: " + Str(X)) 
       Else
       MessageRequester("Bye Bye", "Leaving...")
       Break
    EndIf
    
ForEver

End
PS: What Output() shall I use in order to 2D drawing functions work properly under Linux? ImageOutput()? That means: can I create an Image then use 2D Drawing on it and then show it up within an image gadget?

Thanks in advance...
Derlidio Siqueira
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Strange, I will take a closer look.
Post Reply