[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  Conglutination due to the usage miniwin and utils. since 4.74
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Conglutination due to the usage miniwin and utils. since 4.74

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


Posted by Vbeau   (5 posts)  [Biography] bio
Date Thu 04 Feb 2016 07:58 AM (UTC)
Message
There are problems of conglutination with the main output characters when click "confirm" or "cancel" of utils.msgbox, utils.choose and utils.listbox within a miniwin. The problems of conglutination lead to pause of the main output window.
I found out the version of 4.73 is ok and the problems become more and more serious since 4.74. I write a complete test code formated plugin to demonstrate it.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="BugTest"
   author="WSW"
   id="5c589f1ca4fd208978a46254"
   language="Lua"
   purpose="BugTest"
   date_written="2016-02-02 18:22:02"
   requires="4.73"
   version="1.0"
   >
</plugin>

<script>
<![CDATA[

win = "BugTest"
function OnPluginInstall()
    ColourNote("white", "maroon", "Bug Test For utils.msgbox, utils.choose and utils.listbox")
    WindowCreate(win, 0, 0, 412, 250, 6, 0, ColourNameToRGB("turquoise"))
    WindowFont(win, "f", "宋体", 9, true, false, false, false)

    make_button1()
    make_button2()
    make_button3()    

    WindowShow(win, true)  -- show it
end

make_button1 = function()
	if not button1_flag then
		make_bt_off(10, 30, 70, 70, "lightgreen", "button1", "darkgreen", "button1_down", "button1_down", "click to test the func of utils.msgbox", "button1_up")
	else
		make_bt_on(10, 30, 70, 70, "coral", "button11", "darkred", "button1_up", "button1_up", "click to test the func of utils.msgbox", "button1_down")
	end
end

make_button2 = function()
	if not button2_flag then
		make_bt_off(80, 30, 140, 70, "lightgreen", "button2", "darkgreen", "button2_down", "button2_down", "click to test the func of utils.choose", "")
	else
		make_bt_on(80, 30, 140, 70, "coral", "button22", "darkred", "button2_up", "button2_up", "click to test the func of utils.choose", "")
	end
end

make_button3 = function()
	make_bt_off(150, 30, 210, 70, "lightgreen", "button3", "darkgreen", "button3_down", "button3_down", "click to test the func of utils.listbox", "")
end

button1_down = function()
	button1_flag = true
	make_button1()
	Redraw()
	
	utils.msgbox("Continue?", "Question", "yesno", "?")
end

button1_up = function()
	button1_flag = false
	make_button1()
	Redraw()
	
	utils.msgbox("You finish the test of utils.msgbox")
end

button2_down = function()
	button2_flag = true
	make_button2()
	Redraw()

	local _job_name = {"idle", "beginner"}
	utils.choose("Please choose one of your jobs:", "jobs...", _job_name, 1)
	button2_flag = false
	make_button2()
	Redraw()
end

button3_down = function()
	local _available =  {
	  n = "North",
	  s = "South",
	  e = "East",
	  w = "West",
	  u = "Up",
	  d = "Down",
	  ne = "Northeast",
	  sw = "Southwest",
	  nw = "Northwest",
	  se = "Southeast",
	  ['in'] = "In",
	  out = "Out",
	  }  -- end of available
	
  	local _chosen_exit = utils.listbox("Choose exit to add", "Exits ...", _available )
  	if not chosen_exit then
    	return
  	end	
end

make_bt_off = function(left, top, right, bottom, fillcolor, text, textcolor, hs_name, hs_script, hs_hint, hs_remove)
	WindowRectOp(win, miniwin.rect_draw_edge, left,top,right,bottom,
				  miniwin.rect_edge_raised, 
				  miniwin.rect_edge_at_all + 
					miniwin.rect_option_fill_middle)  

	WindowRectOp(win, miniwin.rect_fill, left+2, top+2, right-2, bottom-2,
				  ColourNameToRGB(fillcolor))
	local textheight  = WindowFontInfo(win, "f", 1)
	local textwidth   = WindowTextWidth(win, "f", text)
	local tex_top_dev = top+((bottom-top)-textheight)/2
	local tex_left_dev = left+((right-left)-textwidth)/2
	WindowText(win, "f",
					text,
					tex_left_dev, tex_top_dev, right-2, bottom-2,
					ColourNameToRGB (textcolor),
					false) 
	WindowDeleteHotspot (win, hs_remove)
	WindowAddHotspot(win, hs_name,
					 left+2, top+2, right-2, bottom-2,
					 "", 
					 "", 
					 hs_script,
					 "", 
					 "", 
					 hs_hint,  
					 miniwin.cursor_hand, 0)  -- hand cursor
end

make_bt_on = function(left, top, right, bottom, fillcolor, text, textcolor, hs_name, hs_script, hs_hint, hs_remove)
	WindowRectOp(win, miniwin.rect_draw_edge, left, top, right, bottom,
				  miniwin.rect_edge_sunken,
					miniwin.rect_edge_at_all + miniwin.rect_option_fill_middle)
	WindowRectOp(win, miniwin.rect_fill, left+2, top+2, right-2, bottom-2,
				  ColourNameToRGB(fillcolor))
	local _textheight  = WindowFontInfo(win, "f", 1)
	local _textwidth   = WindowTextWidth(win, "f", text)
	local _tex_top_dev = top + ((bottom-top)-_textheight)/2
	local _tex_left_dev = left + ((right-left)-_textwidth)/2
	WindowText(win, "f",
					text,
					_tex_left_dev, _tex_top_dev, right-2, bottom-2,
					ColourNameToRGB (textcolor),
					false)
	WindowDeleteHotspot(win, hs_remove)
	WindowAddHotspot(win, hs_name,
					 left+2, top+2, right-2, bottom-2,
					 "",
					 "",
					 hs_script,
					 "",
					 "",
					 hs_hint,
					 miniwin.cursor_hand, 0)  -- hand cursor
end

]]>
</script>


</muclient>
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Thu 04 Feb 2016 03:01 PM (UTC)

Amended on Thu 04 Feb 2016 03:09 PM (UTC) by Fiendish

Message
Vbeau:
For now can you spawn the dialogue boxes on MOUSEUP instead of MOUSEDOWN?


Nick: so you don't have to work so hard to pin this down...

Cyan miniwindow created in upper-right with three buttons.
Click one of the three buttons in the miniwindow and it spawns a dialogue box on MOUSEDOWN. This detail is relevant.

1) If the mouse cursor is outside the bounds of that miniwindow when the dialogue is dismissed, then a drag/highlight event is initiated on the main output which begins selecting text and pauses the display.

2) If the mouse cursor is inside the bounds of that miniwindow when the dialogue is dismissed, then all behaves normally.

This is true regardless of whether the dialogue is dismissed via mouse or keyboard (esc/space).

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 04 Feb 2016 08:00 PM (UTC)

Amended on Thu 04 Feb 2016 08:01 PM (UTC) by Nick Gammon

Message
Thanks, Fiendish.

I can't see any major changes in the release notes for version 4.74 compared to version 4.73. However there *do* seem to be quite a few changes relating to handling of mouse movements in miniwindows:


git diff v4.73..v4.74 -- mushview.cpp


They would have been added to solve other problems. From the release note:

Quote:

4. Fixed some inconsistencies in the way that plugin callbacks were called during miniwindow mouse moves and presses. In particular, WindowInfo (19) and (20) should now return the hotspot relevant to where the mouse is now. Also sometimes it appeared that after a mouse-up, if the mouse was over a hotspot, a new move-over event was not raised. Now it should be.


I don't think there is a simple fix, other than what Fiendish suggested:

Quote:

For now can you spawn the dialogue boxes on MOUSEUP instead of MOUSEDOWN?


You will notice in most operating systems dialog boxes appear when you *release* the mouse, not when you click it. This is probably related to the "mouse capture" problem.




When you click a mouse in a miniwindow it "captures" the mouse:


  SetCapture();       // Capture the mouse until button up.


From the SDK documentation:

Quote:

The SetCapture function sets the mouse capture to the specified window belonging to the current thread. Once a window has captured the mouse, all mouse input is directed to that window, regardless of whether the cursor is within the borders of that window. Only one window at a time can capture the mouse.


This is deliberate, so that you can move the mouse around, possibly straying outside the miniwindow (or MUSHclient itself) without generating random "mouse-over" events elsewhere.

When you release the mouse the capture is released:


  ReleaseCapture();   // Release the mouse capture


Now what you *don't* want to do in your mouse-down script is something that also captures the mouse, like open a dialog box because (from above):

Quote:

Only one window at a time can capture the mouse.


By raising a dialog box, you now shift the capture to the (modal) dialog box when you click Cancel or OK. When you release the mouse the capture is released by the dialog box and the mouse will now behave strangely inside MUSHclient because although the client thinks it captured the mouse, you tricked it into being released.

In the MUSHclient mapper, for example, the "click on room" handler is called on a mouse-up, because it displays dialogs.

In fact in most user-interface places you will notice that actions take place on mouse-up.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


2,063 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]