How do I get mouse events in Texteditor gaget

Discuss GUI programming with the MUI Royale plugin here
Post Reply
User avatar
Redlion
Posts: 95
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

How do I get mouse events in Texteditor gaget

Post by Redlion »

Hi all,

I am trying to get the cursor position after a mouse click in the Texteditor gadget, I can not seem to get MUI Royale to respond to the mouse click.
I have had a look at the Texteditor example that comes with MUI Royale, but am unable to get it to to work.

Code: Select all

@VERSION 5,2
@REQUIRE "MUIRoyale"

@DISPLAY {Hidden = True}

; ** Handles all incoming events
Function p_MUIFunc(msg)
   Switch msg.action
    Case "MUIRoyale":
      Switch msg.attribute
        Case "CloseRequest":
            End
        Case "MouseObject":
          CH=mui.Get("editor","HasChanged")
          if CH > 0
            CC=mui.Get("editor","CursorX")
            CL=mui.Get("editor","CursorY")
            mui.Set("Editor","HasChanged",False)
            mui.Set("Cursor","Contents"," Line : "..CL.."  Column : "..CC)
          endif
        Case "HasChanged":
          CH=mui.Get("editor","HasChanged")
          if CH > 0
            CC=mui.Get("editor","CursorX")
            CL=mui.Get("editor","CursorY")
            mui.Set("Editor","HasChanged",False)
            mui.Set("Cursor","Contents"," Line : "..CL.."  Column : "..CC)
          endif
        EndSwitch

    Case "HideWindow":
      mui.Set("app", "iconified", True)
    Case "ShowWindow":
      mui.Set("app", "iconified", False)
  EndSwitch
EndFunction

; dynamically create MUI GUI
mui.CreateGUI([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app" base="SIMPLE" >
  <window id = "win" title="TEXTEDITOR" muiid="EDIT" appwindow="true" notify="closerequest; mouseobject">
    <vgroup>
    <texteditor Id="Editor" Scrollbar="true" Columns="120" Notify="HasChanged" CycleChain="true" Contents="" />
      <hgroup>
        <string Id="Cursor" Contents=" Line : 0  Column : 0" />
      </hgroup>
    </vgroup>
  </window>
</application>
]])

; listen to these events!
InstallEventHandler({MUIRoyale = p_MUIFunc, HideWindow = p_MUIFunc, ShowWindow = p_MUIFunc})

; main loop!
Repeat
    WaitEvent
Forever 
Here is what I have tried. I think I have all the element that the manual talks about.

Can anyone help.

Thanks
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How do I get mouse events in Texteditor gaget

Post by airsoftsoftwair »

From the manual of Window.MouseObject:
When Window.NeedsMouseObject is enabled for this window, you can setup notificationns on Window.MouseObject to find out on which object the mouse pointer is located.
http://www.hollywood-mal.com/docs/html/ ... ject_.html

Your code doesn't set "NeedsMouseObject" to TRUE so "MouseObject" cannot trigger...
Post Reply