Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 51a930b

Browse files
authored
Merge pull request #6404 from bwmilby/bwm-lcg-demo
[[ Navigation Bar ]] Add option to highlight none of the icons
2 parents d25ddb2 + aa9649b commit 51a930b

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed

extensions/widgets/navbar/navbar.lcb

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The widget displays a row of navigation items. Each of these has a
2525
<itemIcons|icon>, or both. All of the navigation item data is
2626
available as a single array via the <itemArray> property.
2727

28-
At any time, one of the navigation items may be
28+
At any time, zero or one of the navigation items may be
2929
<hilitedItemName|highlighted>. This is useful, for example, for
3030
indicating the current card. When the user clicks one of the
3131
navigation items, the widget sends a <hiliteChanged> message.
@@ -117,7 +117,7 @@ use com.livecode.library.widgetutils
117117

118118
-- adding metadata to ensure the extension displays correctly in livecode
119119
metadata author is "LiveCode"
120-
metadata version is "2.0.0"
120+
metadata version is "2.1.0"
121121
metadata title is "Navigation Bar"
122122
metadata preferredSize is "320,49"
123123
metadata svgicon is "M0,0v29.5h80.2V0H0z M21.1,21.5c-0.2-0.1-0.4-0.2-0.4-0.2c-0.5-0.2-0.9-0.3-1.4-0.4c-0.7-0.1-0.9-0.4-0.9-1.1c0-0.1-0.1-0.9,0-1c0.4-0.2,0.5-0.9,0.5-1.3c0-0.3,0.2-0.5,0.3-0.7c0.2-0.3,0.2-0.6,0.3-0.9c0.1-0.2,0.2-0.6,0.1-0.8c0-0.2-0.2-0.4-0.2-0.6c0-0.3,0.1-0.6,0.1-0.9c0-0.5,0-0.9,0-1.4c-0.2-1.2-1.4-1.6-2.5-1.9c-1-0.2-2.2,0.3-2.9,1c-0.3,0.3-0.6,0.7-0.7,1.1c-0.1,0.4,0,0.9,0,1.2c0,0.2,0,0.4,0.1,0.6c0,0.2,0.1,0.3,0.1,0.5c0,0.1-0.1,0.2-0.1,0.3c-0.2,0.4,0,1,0.2,1.4c0.1,0.2,0.2,0.4,0.3,0.5c0.2,0.2,0.2,0.3,0.2,0.6c0,0.4,0.1,1.2,0.6,1.4c0.1,0.1,0,0.8-0.1,0.9c0,0.7,0,1-0.6,1.1c-0.5,0.1-0.9,0.2-1.4,0.4c-0.2,0.1-0.4,0.2-0.7,0.3c-2-1.4-3.4-3.8-3.4-6.4c0-4.3,3.5-7.8,7.8-7.8s7.8,3.5,7.8,7.8C24.3,17.8,23,20.1,21.1,21.5z M45.1,22.7l-4.9-3.6v-0.7l0.2,0.2l3.6,2.6L42.6,17l-0.1-0.4l0.3-0.3l3.4-2.5H42h-0.4l-0.1-0.4l-1.4-4.2l-1.4,4.2l-0.1,0.4h-0.4h-4.3l3.4,2.5l0.3,0.3L37.5,17l-1.4,4.2l3.6-2.6l0.2-0.2v0.7L35,22.7l1.9-5.9l-4.9-3.6h6.1l1.9-5.9l1.9,5.9h6.1l-4.9,3.6L45.1,22.7z M71.1,23.1l-4.9-4.9c-1,0.9-2.4,1.4-3.9,1.5V19c3-0.1,5.4-2.5,5.4-5.5c0-3.1-2.5-5.5-5.5-5.5c-3.1,0-5.5,2.5-5.5,5.5c0,3,2.4,5.4,5.4,5.5v0.7c-3.4-0.1-6-2.8-6-6.2c0-3.4,2.8-6.2,6.2-6.2c3.4,0,6.2,2.8,6.2,6.2c0,1.5-0.6,2.9-1.5,4l4.9,4.9L71.1,23.1z"
@@ -241,9 +241,11 @@ Description:
241241
The names of the icons displayed by the navigation items when not
242242
highlighted.
243243

244-
Each icon name must be one of the predefined graphics provided by the "IconSVG"
244+
Each icon name must be one of the graphics supplied by the "IconSVG"
245245
library. You can get a list of available predefined path names by running
246-
`put iconNames()` in the Message Box.
246+
`put iconNames()` in the Message Box. See the
247+
<com.livecode.library.iconsvg|Icon SVG Library>
248+
documentation for handlers to manage user icon families.
247249

248250
Setting the <itemIcons> can add items to the navigation bar. If the
249251
new value of the <itemIcons> has more items than the navigation bar,
@@ -256,7 +258,7 @@ navigation bar, the remaining navigation items have their icons reset
256258
to the default icon.
257259

258260
References: hilitedItemIcons(property), itemLabels(property),
259-
itemNames(property)
261+
itemNames(property), com.livecode.library.iconsvg (library)
260262

261263
*/
262264
property itemIcons get getNavIcons set setNavIcons
@@ -273,9 +275,11 @@ Description:
273275
The names of the icons displayed by the navigation items when
274276
highlighted.
275277

276-
Each icon name must be one of the predefined graphics provided by the "IconSVG"
278+
Each icon name must be one of the graphics supplied by the "IconSVG"
277279
library. You can get a list of available predefined path names by running
278-
`put iconNames()` in the Message Box.
280+
`put iconNames()` in the Message Box. See the
281+
<com.livecode.library.iconsvg|Icon SVG Library>
282+
documentation for handlers to manage user icon families.
279283

280284
Setting the <hilitedItemIcons> can add items to the navigation bar.
281285
If the new value of the <hilitedItemIcons> has more items than the
@@ -287,7 +291,8 @@ If the new value of the <hilitedItemIcons> has fewer items than the
287291
navigation bar, the remaining navigation items have their
288292
highlighted-state icons reset to the default icon.
289293

290-
References: itemIcons(property), itemLabels(property), itemNames(property)
294+
References: itemIcons(property), itemLabels(property), itemNames(property),
295+
com.livecode.library.iconsvg (library)
291296
*/
292297
property hilitedItemIcons get getNavSelectedIcons set setNavSelectedIcons
293298
metadata hilitedItemIcons.user_visible is "false"
@@ -354,7 +359,9 @@ Value(integer): The item number of the navigation item that is highlighted.
354359

355360
Description:
356361
The <hilitedItem> is the item number of the currently-highlighted navigation
357-
item, starting from 1. It can be used as a key into the <itemArray>.
362+
item. It can be used as a key into the <itemArray>.
363+
364+
Setting 0 will cause nothing to be highlighted.
358365

359366
Related: hilitedItemName (property)
360367

@@ -365,7 +372,7 @@ metadata hilitedItem.editor is "com.livecode.pi.integer"
365372
metadata hilitedItem.default is "1"
366373
metadata hilitedItem.label is "Selected item index"
367374
metadata hilitedItem.step is "1"
368-
metadata hilitedItem.min is "1"
375+
metadata hilitedItem.min is "0"
369376

370377
/**
371378
Syntax: set the hilitedItemName of <widget> to <pName>
@@ -377,7 +384,7 @@ Value(string): The name of the navigation item that is highlighted.
377384

378385
Description:
379386
The <hilitedItemName> is the name of the currently-highlighted navigation
380-
item.
387+
item. If nothing is highlighted, the value is an empty string.
381388

382389
References: hilitedItem (property)
383390
*/
@@ -1249,7 +1256,7 @@ end handler
12491256

12501257
public handler setNavSelectedItem(in pSelectedItem as Integer) returns nothing
12511258
if pSelectedItem is not mSelectedItem and \
1252-
pSelectedItem > 0 and \
1259+
pSelectedItem >= 0 and \
12531260
pSelectedItem <= the number of elements in mNavData then
12541261
put pSelectedItem into mSelectedItem
12551262
post "hiliteChanged"
@@ -1260,10 +1267,15 @@ end handler
12601267
public handler setNavSelectedItemName(in pName as String) returns nothing
12611268
variable tCount as Integer
12621269
variable tItem as Array
1263-
1270+
1271+
if pName is "" then
1272+
setNavSelectedItem(0)
1273+
return
1274+
end if
1275+
12641276
-- Find the item index corresponding to pName and set it as the
12651277
-- currently-highlighted item.
1266-
1278+
12671279
repeat with tCount from 1 up to the number of elements in mNavData
12681280
put mNavData[tCount] into tItem
12691281
if tItem["name"] is pName then
@@ -1275,7 +1287,11 @@ public handler setNavSelectedItemName(in pName as String) returns nothing
12751287
end handler
12761288

12771289
public handler getNavSelectedItemName() returns String
1278-
return mNavData[mSelectedItem]["name"]
1290+
if mSelectedItem = 0 then
1291+
return ""
1292+
else
1293+
return mNavData[mSelectedItem]["name"]
1294+
end if
12791295
end handler
12801296

12811297
public handler setItemStyle(in pItemStyle as String) returns nothing
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# No Highlight Option
2+
3+
Add an option to have none of the navigation items highlighted.
4+
5+
## Properties
6+
7+
* The **hilightedItem** property has been enhanced to accept a value of
8+
0 which indicates that no items will be highlighted.
9+
10+
## Backward Compatibility Note
11+
12+
* If a stack is saved without an item being highlighted, then when
13+
opened in an earlier version of the widget, a call to
14+
`getNavSelectedItemName` will throw an error if called before an
15+
item is selected.
16+
17+
* The widget will render properly (with nothing highlighted) and issue
18+
the **hiliteChanged** message when an item is selected.

0 commit comments

Comments
 (0)