Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Generic GUI Plugin

Generic GUI Plugin

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 3  

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #15 on Sat 31 Oct 2015 10:57 AM (UTC)
Message
Nick, i've tried that. This is the output:

teste
teste
Hotkey not defined. Type 'hotkey' to set it.

Still don't get it.
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #16 on Sat 31 Oct 2015 11:09 AM (UTC)

Amended on Sat 31 Oct 2015 11:24 AM (UTC) by Halig

Message
I noticed something, if i change this:


  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "hotkey_up", "F"..tostring(hotkey_number), 1, 0)


To this:


  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "F"..tostring(hotkey_number), 1, 0)


It works, but the button stays pressed, uses the pressed image, it doesn't return to the up position.
It just stays a static button.
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #17 on Sat 31 Oct 2015 11:23 AM (UTC)

Amended on Sat 31 Oct 2015 11:24 AM (UTC) by Halig

Message
I've tried another thing:


function hotkey_down (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = true
    update_hotkey (hotkey_number)
    Redraw()
  end -- if
  return 0
end -- hotkey_down


function hotkey_up (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = false
    update_hotkey (hotkey_number)
      Redraw()
  end -- if
  return 0
end -- hotkey_up


This sends the output:

teste
teste

But the button changes to the up picture, so one problem is solved and i removed the message hotkey not defined.
But still getting duplicated command.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #18 on Sat 31 Oct 2015 09:16 PM (UTC)
Message
What do you mean "duplicated command"? When the you get a mouse-down that will call get_hotkey_value and when you release the button it will call get_hotkey_value again.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #19 on Sat 31 Oct 2015 09:56 PM (UTC)
Message
That's the problem. I only need it to send once, when i press the button. When i release the button, i only need the picture to change, nothing more.
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #20 on Sun 01 Nov 2015 12:06 AM (UTC)
Message
Ok, problem solved. Now i have another one.

If you seen the picture, it creates a bar starting on F1 till F12, and a Hotspot or those buttons.


  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)


Now, how can i change that to reflect what i have in those macros? I can type it myself, or make a Global Variable (it doesn't matter), and then when i'm over the F1 button it Hotspots what i said it was on F1, for example, invis.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #21 on Sun 01 Nov 2015 02:49 AM (UTC)
Message
Drawing text and making a hotspot are two different actions.

The hotspot only is a rectangle that generates "events" if you have a mouse-down, mouse-up, mouse-over etc. event on it.

The appearance of the related area of the screen is something you can control with things like WindowText to draw words somewhere inside what you have drawn as the button.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #22 on Sun 01 Nov 2015 10:55 AM (UTC)
Message
Sorry Nick for the confusion.
So i need to check and try to adapt the WindowText.


function outlined_text (colour, window, text, size, x, y)

  outlineColour = colourBlack

  -- write the information inside
  WindowFont(window,'f','Times New Roman',size,1,0,0,0)

  -- smear black text around the location to create an outline, so that it's clearer to read
  WindowText(window,'f',text,x+1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y-1,0,0,outlineColour,0)
  WindowText(window,'f',text,x,y+1,y,0,outlineColour,0)
  WindowText(window,'f',text,x,y-1,y,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y-1,0,0,outlineColour,0)

  -- display the text
  WindowText(window,'f',text,x,y,0,0,colour,0)

end -- outlined_text


The only place where i have WindowText is in this function. So this function creates the text in the little balloon?
I've created the macros that you teached me earlier in this post, one for every F key, so i have macro1 to macro12. How can i set, lets say, keywords for everyone of those macros? I can write them manually but i want them to be displayed.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #23 on Mon 02 Nov 2015 04:52 AM (UTC)
Message
It looks to me that you call that function to draw the text at a specified X/Y location.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #24 on Mon 02 Nov 2015 05:16 PM (UTC)
Message
Correct Nick. That's my understanding of that too. But how do i change what it draws?
The function that calls this one is:


function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  button = "images/layout/button_background.png"

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)

end -- create_hotkey


function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")
    button = "images/layout/button_background.png"
 
    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

end -- update_hotkey


When it creates the hotkeys, it draws the F1 to F12 on the bottom of the button. That is like that, no worries.
Now, it reads what is in the hotkeys_name (i think) and that is what i want to change, so the button will show on the bottom the key (F1 to F12) and in the middle, some text that i define, let's say on the F1 - Help.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #25 on Tue 03 Nov 2015 03:08 AM (UTC)
Message
You seem to be on the right track. How about doing a debugging print as you try to draw the name?


print (hotkeys_name[hotkey_number])


That will confirm you actually have a name there.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #26 on Tue 03 Nov 2015 02:36 PM (UTC)
Message
Hi Nick, I've inserted that line, in the function create_hotkey and the function update_hotkey.
The returned print is always nil, so it is not updating anything and i can't see what to change in order to define myself what is there.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #27 on Tue 03 Nov 2015 07:46 PM (UTC)
Message
Reply #7 covered that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Halig   Portugal  (123 posts)  Bio
Date Reply #28 on Tue 03 Nov 2015 08:20 PM (UTC)
Message
Correct. I've tried that, and still nil, if i use:


print (hotkeys_name[hotkey_number])


It seems that it doesn't update. If i press the button, it sends the command correctly, so everything is good at that end.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #29 on Tue 03 Nov 2015 09:17 PM (UTC)
Message
Halig said:

Correct. I've tried that, and still nil, if i use:



Can you post that code please?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


78,799 views.

This is page 2, subject is 3 pages long:  [Previous page]  1  2 3  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.