`
nlslzf
  • 浏览: 1026773 次
  • 性别: 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();">
分享到:
评论

相关推荐

    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 ...

    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.

    Vue + Element-ui的下拉框el-select获取额外参数详解

    直接上代码吧~ 用户类型 width=180&gt; &lt;template slot-scope=scope&gt; &lt;el v-model=scope.row.... placeholder=请选择 change=changeRole($event,scope)&gt; &lt;el-option v-for=item in roles :key=item.value :l

    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 ...

    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:...

    linux下安装ImageMagick-6.5+JMagick -6.4 经测试成功的

    *-----------/ *安装jpeg包: http://www.ijg.org/files/jpegsrc.v6b.tar.gz tar -zvxf jpegsrc.v6b.tar.gz cd jpeg-6b/ ./configure --enable-shared --enable-static ; make ; make install *安装png包:先在...

    μC/OS-II, The Real-Time Kernel

    have to change include files and product build files to ‘point’ to the new file names. This book contains ALL the source code for μC/OS-II and a port for the Intel 80x86 processor running in ...

    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 \ / +----------+ \ ...

    Image-analysis-classifaction-and-change-detection-in-remote-sensing-with-algorithms-for-ENVI-IDL-and-Python.pdf.pdf

    Image-analysis-classifaction-and-change-detection-in-remote-sensing-with-algorithms-for-ENVI-IDL-and-Python.pdf

    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 ...

    TPFanControl 0.63准绿色版+教程

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

    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 ...

    search engine marketing

    The second edition updates all chapters with the important developments in search marketing, including the sea change in paid search toward hybrid auctions, the advent of sitemaps to index your ...

    delphi 7 gif控件

    // The result is best if each sub frame contains a whole image. // // If the sub frame is transparent the background is not automatically // // restored, you must do so yourself if you want that. // /...

    sciter-sdk-4.0.0.7

    [win] elements with attached windows, fix of visibility change. [win] behavior:file-thumbnail fix. [printing] fix of AV while loading printing templates into "normal" frames. [css] custom properties +...

Global site tag (gtag.js) - Google Analytics