`
nlslzf
  • 浏览: 1044957 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Change font size in the whole app with Ctrl+/-

    博客分类:
  • flex
阅读更多
http://feedproxy.google.com/~r/flexorg/~3/XfQJ3GkTo-E/change-font-size-whole-app-ctrl

Problem
Browser supports changing page font size with C+/- and Ctrl+scrolling, but Flex applications are not affected by this. People with failing sight can not use such applications.

Solution
Work with StyleManager and set "fontSize" at runtime.

Detailed explanation
There is a simple way to change font size in the Flex application. This works through styles without any serious restrictions (+ view source). For CSS classes that use greater or smaller font size "fontSizeDelta" style should be specified with the delta for example 2 or -1:

<mx:Style>
   
    .header
    {
        fontSizeDelta: 3;
    }
   
</mx:Style>
Code that actually changes the font size:

private function applyFontSize(fontSize:Number):void
{
    // Loop through all styles and set
    // new "fontSize" value based
    // on new size and "fontSizeDelta" style
    var selectors:Array = StyleManager.selectors;
    for each (var selector:String in selectors)
    {
        var declaration:CSSStyleDeclaration =
StyleManager.getStyleDeclaration(selector);
        var delta:Number = declaration.getStyle("fontSizeDelta");
        if (delta)
        {
            declaration.setStyle("fontSize", fontSize + delta);
            StyleManager.setStyleDeclaration(selector, declaration,
false);
        }
    }
   
    // global style is applied to all Flex visual components
    var global:CSSStyleDeclaration =
StyleManager.getStyleDeclaration("global");
    if (!global)
        global = new CSSStyleDeclaration("global");
    global.setStyle("fontSize", fontSize);
    // update styles only on last change
    StyleManager.setStyleDeclaration("global", global, true);
}

private function addedToStageHandler():void
{
    stage.addEventListener(KeyboardEvent.KEY_UP, my_keyUpHandler);
}

private function my_keyUpHandler(event:KeyboardEvent):void
{
    if (event.ctrlKey)
    {
        var keyCode:uint = event.keyCode;   
        // Ctrl +/up
        if (keyCode == 107 || keyCode == 187 || keyCode == 38)
            fontSize++;
        // Ctrl -/down
        else if (keyCode == 109 || keyCode == 189 || keyCode == 40)
            fontSize--;
    }
}
In order to make Ctrl+/- rigth after application starts (without clicking on it to give focus), set focus automatically:

<body scroll='no'
onLoad="document.getElementById('${application}').focus();">
分享到:
评论

相关推荐

    mysql示例数据库 employee

    +--------------+------------------+----------------------------------+ | table_name | expected_records | expected_crc | +--------------+------------------+----------------------------------+ | ...

    The+Tao+of+Microservices-Manning(2017).pdf

    Along the way, you�ll dig deep into detailed case studies with source code and documentation and explore best practices for team development, planning for change, and tool choice.

    Eclipse中10个最有用的快捷键组合

    **Ctrl + M - 改变编辑器大小(Change Editor Size)** - **用途**:调整编辑器窗口的大小。 - **应用场景**:根据个人喜好或当前工作需求调整编辑器窗口的尺寸,便于查看代码。 #### 10. **Ctrl + . / Ctrl + 1 ...

    IRPTrace2.00.002.zip

    We strongly recommend that you read the following information about this release. 1) IRPTrace Components ===================== README.TXT - This file HOWTOREG.TXT - How to register IRPTrace and ...

    Protel 快捷键

    - **图纸尺寸调整:** F4 (Change Sheet Size) - **图纸属性查看:** FP (Sheet Properties) - **图纸层管理:** FO (Sheet Layers) - **图纸层显示:** FS (Show Sheet) - **图纸层隐藏:** FH (Hide Sheet) ##### 4. ...

    edison-debian-image:基于 ubilinux 的用于闪存 Intel Edison 的 ext4 分区

    /+-- bin/+-- boot/+-- dev/+-- etc/|+-- alternatives/|+-- ...|+-- network/||+-- if-down.d/||+-- ...||+-- if-pre-up.d/|||+-- change-mac ** :: When the lo interace is loading on boot, change the

    unigui0.83.5.820

    +---------------------------------------------------------------------------------------- - 0000796: DBGrid: Render bug when Column color is clWindow and project is created with 0.82 - 0000795: Grid:...

    idea 快捷键

    - **Change Font Size (Ctrl+Shift+NumPad+/-)**:改变字体大小。 - **Move Line Up/Down (Alt+Up/Down)**:移动行上/下。 - **Split Editor Horizontally (Ctrl+] )**:水平分割编辑器。 - **Split Editor ...

    Java+9+Programming+By+Example-Packt+Publishing(2017).pdf

    Java drastically changed with the introduction of Java 8, and this change has been elevated to a whole new level with the new version, Java 9. Java has a well-established past, being more than 20 ...

    ASP.NET+Core+2+and+Angular+5-Packt+Publishing(2017).pdf

    Modern web technologies are still improving at lightning-fast speed, with an increasing, perceptible, and measurable interest being in the client-side aspects of the game. Angular, React, and VueJS ...

    kgb档案压缩console版+源码

    -----+--------------------+-------------+-------------+ | | | | V V | | +---------+ n0, n1 +----------+ | | | Model 1 |---------&gt;| Mixer 1 |\ p | | +---------+ \ / | | \ V V \ / +----------+ \ ...

    TPFanControl 0.63准绿色版+教程

    // change for your purposes. // 注意,下面的温度设置是以我的T61为例,特别是蓝牙EDR设置为1,第五个传感器名称改为no5,并且忽略这个传感器的温度显示.在T4X,R5X机器上,温度设置要高个10°,总之以你自己实测的效果来...

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    - fixed bug with lost of focus in font size combo-box in designer - fixed bug with truncate of font size combo-box in Windows Vista/7 in designer (lost of vertical scroll bar) - fixed bug when lost ...

    Geoprocessing-with-Python.pdf

    Although I’d taken a lot of programming classes in college, I never fully appreciated programming until I had a job that involved a lot of repetitive tasks. After amusing myself by automating much of...

    Big+Data,+Crime+and+Social+Control-Routledge(2018).pdf

    Keeping up with the fast pace of surveillance and data collection is one of the main political challenges of our time. We are dealing here with a phenomenon that is so massive, that changes so quickly...

    QHierarchy 4.2 最新版Unity插件

    - Displaying the list of GameObjects in the form of a tree - Option to add right indent (useful if you use other plugins that add another icons to the hierarchy window) - Any feature can be disabled ...

    Intellij IDEA操作手册.docx

    - **操作**:选择`Mouse`选项卡下的`Change font size with Ctrl + Mouse Wheel`进行设置。 - **作用**:通过此设置,用户可以通过Ctrl键与鼠标滚轮结合使用来调整编辑器中的字体大小,提高编程时的视觉舒适度。 **...

    Eclipse快捷键

    - **Ctrl+/ 或 Ctrl+\***:注释或取消注释当前行 - **Ctrl+O**:显示Outline视图 - **Ctrl+T**:显示当前文件的类层次结构 - **Ctrl+W**:关闭当前编辑器 - **Ctrl+K**:选择到单词的开头 - **Ctrl+E**:显示最近...

Global site tag (gtag.js) - Google Analytics