Startseite › Foren › Deutsches LiveCode-Forum › Font-Liste beschränken › Antwort auf: Font-Liste beschränken
Mai 24, 2019 um 01:27 Uhr
#15053
Guten Morgen,
auf Klaus‘ Vorschlag von 15:54h habe ich mal hier
Livecode xxx.app/Contents/Tools/Toolset/palettes/menubar/revmenubar.livecodescript
gestöbert.
Jetzt habe ich einen Stapel mit 2 Zeichensatzlisten:
• alle Computer-Zeichensätze,
• durch Zeilenklick ausgewählte Zeichensätzew.
Die Taste [pd] soll nur ‚meine‘ Fonts (‚UserFontList‘),
die Taste [LC] soll alle Zeichensätze in LiveCodes Text-Menu anbieten.
[LC] hat dieses Script:
on MouseUp
SetUpTextMenu "LC"
end MouseUp
[pd] hat dieses Script:
on MouseUp
SetUpTextMenu "pd"
end MouseUp
Das Stapel-Skript sieht so aus:
private on setupTextMenu ModeX
put fld "UserFontList" into UserFontList
if UserFontList = "" then
beep 3
answer "User Font List is empty ..."
exit to Top
end if
local tText
put toggleMenuItem("Plain/;", false) & return after tText
put toggleMenuItem("&Bold/B", false) & return after tText
put toggleMenuItem("&Italic/I", false) & return after tText
put toggleMenuItem("&Underline/U", false) & return after tText
put toggleMenuItem("Strikeout", false) & return after tText
put toggleMenuItem("Box", false) & return after tText
put toggleMenuItem("3D Box", false) & return after tText
put "-" & return after tText
put toggleMenuItem("Link", false) & return after tText
put "-" & return after tText
put toggleMenuItem("Subscript", false) & return after tText
put toggleMenuItem("Superscript", false) & return after tText
put "-" & return after tText
put "Font" & return after tText
local tFontNames
if ModeX = "LC"
then put the FontNames into tFontNames
else put UserFontList into tFontNames
replace "/" with "\" in tFontNames
sort lines of tFontNames
beep
put ModeX & cr & tFontNames
/* Fake fonts begin with "(", but the menu code interprets a "(" at
the beginning of the item to mean the item is disabled.
So, to show a "(" instead of disabling, we need to double it */
repeat with tLine = 1 to the Number of lines of tFontNames
if line tLine of tFontNames begins with "(" then
put "(" before line tLine of tFontNames
end if
end repeat
put "Use Owner's Font" & return & "-" & return before tFontNames
local fontnum
put 1 into fontnum
repeat for each line tFontName in tFontNames
if tFontName is "-" then
put tab & tFontName & return after tText
else
put "!u" & tab & tFontName & return after tText
end if
end repeat
put "Size" & return after tText
local tFontSizes
put Format("Use Owner's Size\n-\n8\n9\n10\n12\n14\n18\n24\n36\n48\n-\nOther...") into tFontSizes
repeat for each line l in tFontSizes
if l is "-" then put tab & l & cr after tText
else put "!u" & tab & l & cr after tText
end repeat
put "Color" & cr after tText
local tColors
put Format("Use Owner's Color\n-\nBlack\nWhite\nRed\nGreen\nBlue\nYellow\n-\nPen Color") into tColors
repeat for each line tColor in tColors
if tColor is "-" then
put tab & tColor & return after tText
else
put "!u" & tab & tColor & return after tText
end if
end repeat
put "-" & return & "&Align" & return & "!u" & tab & "Left" & return & "!u" & tab & "Center" & return & "!u" & tab & "Right" after tText
# Cache the text menu text in non-disabled state
put tText into sTextMenuText
repeat for each line tLine in tText
if the Platform is "MacOS" and tab is in tLine then
replace tab with empty in tLine
local tDisabledText
put tab & "(" & tLine & return after tDisabledText
else
put "(" & tLine & return after tDisabledText
end if
end repeat
delete last char of tDisabledText
# Cache the disabled text menu text
put tDisabledText into sTextMenuDisabledText
beep
put tDisabledText
end setupTextMenu
---
function toggleMenuItem pItem, pHilited
if pHilited then
return "!c" & pItem
end if
return "!n" & pItem
end toggleMenuItem
Noch läuft es nicht wie gewünscht; so zeigt das Text-Menu unverändert die (volle) Computer-Font-Liste.
Bis später
Peter