Add proxy signals for item mouse events (issue #10 )
This commit is contained in:
parent
b65f47e86b
commit
0a74963b41
23
README.md
23
README.md
|
@ -235,8 +235,27 @@ here is the list:
|
||||||
| append | Append an existing (but unused) item | the item | --- |
|
| append | Append an existing (but unused) item | the item | --- |
|
||||||
|
|
||||||
|
|
||||||
Menu also emit many signals, the syntax is usually `PROPERTY_NAME::changed`. The
|
Menu also emit many signals, the syntax is usually `PROPERTY_NAME::changed`.
|
||||||
exeptions are `item::moved`, `item::swapped`, `item::removed`, `item::appended`
|
Some others are `item::moved`, `item::swapped`, `item::removed`, `item::appended`
|
||||||
|
|
||||||
|
Most item_layout also repackage the default widget signals. It usually does the
|
||||||
|
same as using the `buttonX` menu attributes, but is preferrable in some scenarios
|
||||||
|
|
||||||
|
| Name | Description | Arguments |
|
||||||
|
| ----------------- | ---------------------------------- | ------------------- |
|
||||||
|
| button::press | A button press | menu,item,button_id |
|
||||||
|
| button::release | A button release | menu,item,button_id |
|
||||||
|
| mouse::enter | When the mouse enter | menu,item |
|
||||||
|
| mouse::leave | When the mouse leave | menu,item |
|
||||||
|
|
||||||
|
An example of how to use them:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local menubar = radical.bar{}
|
||||||
|
menubar:connect_signal("button::press",function(data,item,button)
|
||||||
|
print("Foo!",item.text,button,data.rowcount)
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
###Beautiful options
|
###Beautiful options
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ local function new(screen)
|
||||||
bg_hover = beautiful.menu_bg_focus,
|
bg_hover = beautiful.menu_bg_focus,
|
||||||
disable_markup = true,
|
disable_markup = true,
|
||||||
overlay = function(data,item,cd,w,h)
|
overlay = function(data,item,cd,w,h)
|
||||||
print("foo!")
|
-- print("foo!")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,19 @@ local function create_item(item,data,args)
|
||||||
item._internal.text_w = text
|
item._internal.text_w = text
|
||||||
item._internal.icon_w = nil
|
item._internal.icon_w = nil
|
||||||
item._internal.margin_w = m
|
item._internal.margin_w = m
|
||||||
|
|
||||||
|
bg:connect_signal("button::press",function(b,t,s,id,e)
|
||||||
|
data:emit_signal("button::press",data,item,id)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("button::release",function(b,t)
|
||||||
|
data:emit_signal("button::release",data,item,id)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("mouse::enter",function(b,t)
|
||||||
|
data:emit_signal("mouse::enter",data,item)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("mouse::leave",function(b,t)
|
||||||
|
data:emit_signal("mouse::leave",data,item)
|
||||||
|
end)
|
||||||
return bg
|
return bg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,19 @@ local function create_item(item,data,args)
|
||||||
item._internal.icon_w = icon
|
item._internal.icon_w = icon
|
||||||
item._internal.margin_w = m
|
item._internal.margin_w = m
|
||||||
|
|
||||||
|
bg:connect_signal("button::press",function(b,t,s,id,e)
|
||||||
|
data:emit_signal("button::press",item,id)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("button::release",function(b,t)
|
||||||
|
data:emit_signal("button::release",item,id)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("mouse::enter",function(b,t)
|
||||||
|
data:emit_signal("mouse::enter",item)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("mouse::leave",function(b,t)
|
||||||
|
data:emit_signal("mouse::leave",item)
|
||||||
|
end)
|
||||||
|
|
||||||
return bg
|
return bg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,20 @@ local function create_item(item,data,args)
|
||||||
|
|
||||||
item._internal.text_w = text_w
|
item._internal.text_w = text_w
|
||||||
item._internal.icon_w = icon
|
item._internal.icon_w = icon
|
||||||
|
|
||||||
|
bg:connect_signal("button::press",function(b,t,s,id,e)
|
||||||
|
data:emit_signal("button::press",data,item,id)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("button::release",function(b,t)
|
||||||
|
data:emit_signal("button::release",data,item,id)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("mouse::enter",function(b,t)
|
||||||
|
data:emit_signal("mouse::enter",data,item)
|
||||||
|
end)
|
||||||
|
bg:connect_signal("mouse::leave",function(b,t)
|
||||||
|
data:emit_signal("mouse::leave",data,item)
|
||||||
|
end)
|
||||||
|
|
||||||
return bg
|
return bg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue